FastPrepIn-Memory Vault File System
Problems/In-Memory Vault File System

In-Memory Vault File System

Harvey logoHarvey● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report describes an in-memory vault with add-file and get-files operations, and suffixes added before the extension when names collide. It does not give directory creation, the scope and order of listings, how exactly a collision is resolved, or a finite interface. Our version is about 90% the same as the reported question.

Implement an in-memory vault that stores files in directories. You are given equal-length arrays operations and paths.

Process each operation in order:

  • add_file stores the file at the absolute path paths[i]. Missing parent directories are created automatically. If that exact filename already exists in its directory, insert (x) immediately before the final extension, where x is the smallest positive integer that produces an unused filename. The final extension begins at the last period when that period is neither the first nor the last character. A filename without such an extension receives (x) at the end.
  • get_files treats paths[i] as an absolute directory path and returns the names of its immediate files in lexicographic order. A missing or empty directory returns an empty list.

Return one row for every get_files operation, in the order those queries occur. File names in a row do not include the directory prefix.

Function

runVault(operations: String[], paths: String[]) → String[][]

Examples

Example 1

operations = ["add_file","add_file","add_file","get_files"]paths = ["/docs/report.txt","/docs/report.txt","/docs/image.png","/docs"]return = [["image.png","report(1).txt","report.txt"]]

The second report collides with report.txt, so it becomes report(1).txt. The query lists only immediate files in sorted order.

Example 2

operations = ["add_file","add_file","get_files","get_files"]paths = ["/a/b/note","/a/c/note","/a/b","/a"]return = [["note"],[]]

The first query sees the immediate file in /a/b. The vault does not return descendant files recursively, so querying /a returns an empty list.

Constraints

  • 0 <= operations.length <= 200000.
  • operations.length == paths.length.
  • Every operation is add_file or get_files.
  • Every path is absolute, uses a single / separator between nonempty components, and contains neither . nor .. directory components.
  • An add_file path contains at least one directory and one nonempty filename.
  • Path components contain lowercase English letters, digits, hyphens, underscores, and periods.
  • The total path length across all operations is at most 1000000.

More Harvey Onsite Interview questions

  • Highlight and Rank Overlapping CitationsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • File System Shell CommandsONSITE INTERVIEW · Seen Nov 2026
  • Spreadsheet Formula EvaluatorPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Retrieve Vectors by Cosine SimilarityONSITE INTERVIEW · Seen Nov 2026
  • Evaluate an Expression MapONSITE INTERVIEW · Seen Sep 2026
  • Find Duplicate Files in a FilesystemPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Highlight Matching PhrasesPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEW
  • Account Scheduler - Availability and AcquireStripe · ONSITE INTERVIEW
  • In-Memory Directory and File OperationsSquarepoint Capital · ONSITE INTERVIEW
  • In-Memory Spreadsheet ValuesRippling · PHONE SCREEN · ONSITE INTERVIEW
  • Feature Flag Evaluation EngineCresta · ONSITE INTERVIEW
  • Card Transaction StreamCapital One · ONSITE INTERVIEW
  • Return Every Matching DecryptionDuolingo · PHONE SCREEN
  • Parcel Event TrackingAirbnb · OA
  • Reference-Counted Deduplicating File SystemCitadel · PHONE SCREEN
  • Machine Message RouterOpenAI · PHONE SCREEN
See Harvey hiring insights
Saved
class Solution {
    public String[][] runVault(String[] operations, String[] paths) {
      // write your code here
    }
}
Checking account…