Problem · Graph

Unix-Like File Search with Composable Filters

MediumAmazon logoAmazonNEW GRADPHONE SCREEN
See Amazon hiring insights

Problem statement

There are n nodes identified by index. paths[i] is node i's unique canonical absolute path. kinds[i] is 0 for a directory, 1 for a regular file, or 2 for a symbolic link. sizes[i] is a regular file's size in bytes. For a directory, children[i] lists its direct child node IDs. For a symbolic link, linkTargets[i] is its target node; all other entries are -1.

The problem statement continues
Pro

Examples

Example 1

paths = ["/","/logs","/logs/app.log","/logs/app.tmp","/latest"]kinds = [0,0,1,1,2]sizes = [0,0,900,120,0]children = [[1,4],[2,3],[],[],[]]linkTargets = [-1,-1,-1,-1,1]root = 0nameContains = ".log"minSize = 500return = ["/logs/app.log"]

The regular log file satisfies both filters. The symbolic link reaches the same directory, but node identity prevents duplicate traversal.

FastPrep Pro
Reported in 1 Amazon interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 1 more worked example, explained
  • Guided hints and editorial
  • Run your code on real test cases
$9/month

Pro subscription, billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 Amazon interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 1 more worked example, explained
  • Guided hints and editorial
  • Run your code on real test cases
$9/month

Pro subscription, billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week