FastPrepSearch a File Collection
Problems/Search a File Collection

Search a File Collection

Google logoGoogle● EasyNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report asks for object-oriented methods that add files to a collection and find them. We use a finite list of operations, and we set how filenames match, how results are ordered, and what happens when the same file is added twice.

Process an ordered batch of operations on an initially empty collection of unique, case-sensitive file paths.

  • ADD path stores the path. Adding an existing path changes nothing.
  • FIND fragment finds every stored path whose final filename contains fragment. Return matching paths in lexicographic order, joined by |, or NONE when 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

Interview reports that mention this question

  • Google New Grad Four-Round Virtual Onsite: 1 Experience

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public String[] searchFiles(String[] operations) {
        // Write your code here.
    }
}
Checking account…