Search a File Collection
Updated
Problem statement
Process an ordered batch of operations on an initially empty collection of unique, case-sensitive file paths.
ADD pathstores the path. Adding an existing path changes nothing.FIND fragmentfinds every stored path whose final filename containsfragment. Return matching paths in lexicographic order, joined by|, orNONEwhen no path matches.
Return one result string for each FIND operation; ADD operations do not add output entries.
Function
searchFiles(operations: String[]) → String[]Examples
Example 1
operations = ["ADD /docs/report.txt","ADD /tmp/notes.txt","FIND .txt","FIND port"]return = ["/docs/report.txt|/tmp/notes.txt","/docs/report.txt"]Both text files match the first query; only report.txt contains port.
Example 2
operations = ["ADD /a/photo.png","ADD /b/photo.png","ADD /a/photo.png","FIND photo","FIND .jpg"]return = ["/a/photo.png|/b/photo.png","NONE"]Duplicate insertion is ignored, and the second query has no matches.
Constraints
1 <= operations.length <= 10^4- Paths and fragments are nonempty printable strings without spaces or
|. - Every path contains at least one filename character after its final slash.
More Google Phone Screen questions
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
- Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
- Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
- Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Logger Rate Limiter with Every-Arrival HistoryPHONE SCREEN · Seen Nov 2026
Similar questions at other companies
- In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
- Text Embedding and Vector SearchNike, Inc. · PHONE SCREEN · ONSITE INTERVIEWNike, Inc. interview questions
- Sort Words by LengthMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Query JSON Records with WHERE and ORDER BYGitHub · ONSITE INTERVIEW
- Versioned Recipe SystemThe Trade Desk · OA
- Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
- Portfolio Valuation, Part 1Stripe · PHONE SCREENStripe interview questions
- Summarize Server Healthcheck LogsNVIDIA · PHONE SCREENNVIDIA interview questions
- Parse and Sort Integer DataLegora · PHONE SCREEN
- Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions