Unix-Like File Search with Composable Filters
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.
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.
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
Pro subscription, billed yearly — or $19 month-to-month. Cancel anytime.