Directory Search Library
MediumProblem Description
Implement a small in-memory directory search API.
You are given a directory tree where each node has:
name: stris_file: boolsize: int(bytes, only meaningful for files)children: List[node](only for directories)
Write:
findMatchingPaths(root, min_size, extension) -> List[str]
Requirements:
- Return file paths that match all provided filters.
- If
min_sizeisNone, ignore size filter. - If
extensionisNone, ignore extension filter. - Use composition-style matcher logic, not hardcoded nested conditions.
- Output should be sorted lexicographically for deterministic results.
Example
min_size = 5_000_000
extension = "xml"
=> return all .xml files >= 5MB
Follow-up
- Add
or/notmatchers. - Add cycle protection if symbolic links are introduced.
Solution
Test Results
Click "Run Tests" to execute your solution against test cases.
AI Interviewer
I'll review your code once you submit it. I can also give you hints if you get stuck!