Design a File Search and Directory Traversal System
Design and implement a file search system that can traverse directory structures and locate files based on various criteria. The solution should incorporate object-oriented programming principles, support extensible filtering mechanisms, and be optimized for performance. Consider implementing algorithms like DFS or BFS for traversal, and discuss scalability considerations for adding new search filters and optimizations such as byte-level operations.
Asked at:
Meta
Anduril
Amazon
Atlassian
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early June, 2026
Anduril
Mid-level
Early April, 2026
Amazon
Senior
You are asked to design a reusable library that allows searching files in a filesystem, similar to the Unix find command. This library will be used by other teams, so it must be: • Extensible • Easy to use • Independent of any specific filesystem implementation Implement a main function: find(root, filter) -> List<File> Where: • root: starting directory for the search • filter: search criteria applied to files The library must support filtering files based on: • Name (e.g., "*.txt") • Size (e.g., greater than X bytes) • Type (file or directory) The system must allow combining filters using logical operators: • AND • OR • (Optional) NOT Examples: (name = "*.log") AND (size > 1MB) (name = "report.txt") OR (size < 10KB)
Early March, 2026
Meta
Senior
Hello Interview Premium
Your account is free and you can post anonymously if you choose.