Reported September 2026
Harveydesign

In-Memory Vault File System

Reported by candidates from Harvey's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Harvey OA. Under 2s to a working solution.
Founder's read

The mistake that sinks a first attempt at Harvey's In-Memory Vault File System, reported in September 2026, is treating the rename rule as a one-shot check. Candidates append (1), see it's taken too, and the code breaks. This is a design problem wearing a string-parsing costume. You map directory paths to file collections, handle duplicate names with the smallest free (x), and answer sorted listings of immediate files only. Input can reach 200000 operations, so sloppiness gets punished. If you blank during the live OA, StealthCoder sits invisibly on your screen as a safety net. Know the shape before you open the assessment.

The problem

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.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Use a hash map from directory path to a set of filenames. For add_file, split at the last slash into directory and filename. If the name is free, insert it. If not, find the extension split: the last period counts only if it's not the first and not the last character. Then try (1), (2), and so on until a name is unused. The pitfall is the rename loop going quadratic on repeated adds of the same file. Keep a per-directory map from base filename to the next counter to try, and still confirm the candidate is unused, since a user may have added report(1).txt directly. For get_files, sort the directory's names at query time, or keep them sorted if queries are frequent. Missing directories return an empty list. Don't create ancestor entries, because listings are not recursive. StealthCoder is the hedge if the extension edge cases slip your mind live.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill In-Memory Vault File System cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Harvey's OA.

Harvey reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

In-Memory Vault File System FAQ

What's the trick in the Harvey vault problem?+

Key a hash map by the full directory path and store filenames per directory. Parent directories need no explicit creation since queries aren't recursive. The real work is the duplicate-name rule and the extension parsing, so write those as a small helper and test it first.

How do I find the extension correctly?+

Find the last period in the filename. It counts as an extension start only if its index is greater than 0 and less than length minus 1. Otherwise there's no extension and (x) goes at the end. So.bashrc becomes.bashrc(1) and file. becomes file.(1).

Will repeated duplicates be too slow?+

They can be. Trying (1), (2), (3) from scratch on each add goes quadratic when the same file is added many times. Store a counter per directory and base name to resume from the last used value, while still checking the set for collisions.

Does get_files include files in subdirectories?+

No. Example 2 shows querying /a returns an empty list even though /a/b and /a/c hold files. Only immediate files in the exact directory are returned, sorted lexicographically, and a missing directory gives an empty list.

How do I prepare for this in 48 hours?+

Write the solution once from scratch. Cover edge cases: a filename starting with a period, one ending with a period, multiple periods, and a pre-existing (1) name. Then check sorted output and the empty-query case. Use sorting at query time unless you expect heavy repeated queries.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Harvey.

OA at Harvey?
Invisible during screen share
Get it