Implement a Fuzzy File Finder
Last updated: May 21, 2025
Quick Overview
Implement a fuzzy file finder that takes a query string and a list of file paths as input, returning a list of file paths that match the query based on subsequence matching. The solution should score the matches based on their quality and ensure efficient performance for large datasets, allowing for quick retrieval of relevant files.
Cursor
May 21, 20257
11
4,486 solved
Implement a fuzzy file finder that takes a query string and a list of file paths as input, returning a list of file paths that match the query based on subsequence matching. The solution should score the matches based on their quality and ensure efficient performance for large datasets, allowing for quick retrieval of relevant files.
Every code editor has a fuzzy file finder (Cmd+P). This question tests your ability to implement a practical algorithm that balances match quality with performance. The scoring algorithm should prefer consecutive character matches, matches at word boundaries, and matches near the end of the path.
What the Interviewer Expects
- Implement subsequence matching between a query and file paths
- Design a scoring function that ranks results by match quality
- Achieve sub-50ms response times for projects with 100K+ files
- Handle case-insensitive matching with case-sensitive bonus scoring
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you handle a query that matches thousands of files?
- How would you update the index when files are added or removed?
- How would you incorporate recent file history into the ranking?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Problem Analysis
To solve the fuzzy file finder problem, we can utilize a subsequence matching approach. The goal is to check if the query string is a subsequence of each file path. This pattern is applicable here...
Approach
- Input Parsing: Read the query string and the list of file paths.
- Subsequence Check: For each file path, check if the query string is a subsequence. This can be done using two pointers: o...