The round is one problem built up across four parts, asked on both the phone screen and the onsite from the same bank, and known in the reports as "the vault question." Seven reports call it the easiest problem Harvey asks. One candidate finished every part in 45 minutes. The interviewer writes and runs their own test cases as you go, and does not always announce the rule a test is checking.
Implement an in-memory hierarchical file store. The original report's own description of the structure: "just a dict of dicts, passed down one level at a time."
Given — the API as the original report states it
class FileSystem:
def add_file(self, path: str, content: str | None = None) -> str:
"""Store a file at 'path/to/somewhere/file.txt', creating missing folders."""
def add_folder(self, path: str) -> str:
"""Create a folder, creating missing parents."""
def get_file(self, path: str):
"""What lives at path: get_file('path/to/somewhere') -> file.txt,
get_file('path/to') -> the folder 'somewhere'. Raise if nothing is there."""
Part 1 — add_file(), add_folder(), get_file()
Part 2 — at most 5 entries per directory
Part 3 — duplicate names
file.txt, file(1).txt, file(2).txt.file.txt, file.txt, then file(1).txt. The third must become file(1)(1).txt, not file(2).txt. The counter wraps the whole current name.a (1).txt. Ask which form the interviewer wants before coding.fs.add_file("file.txt") # file.txt
fs.add_file("file.txt") # file(1).txt
fs.add_file("file(1).txt") # file(1)(1).txt
Part 4 — two questions, no code
The reported wall — not the code. Because the problem is easy, the round is decided on the follow-ups, the live tests, and how you hold up under pushback. The original report's interviewer challenged the approach several times before the tests ran and then conceded. One candidate solved every part with a trie and was rejected without explanation. Solve it cleanly, ask about the rename rule up front, and keep your composure.
How would you handle duplicate file names in the same directory?
Add a constraint: each directory can hold at most 5 items (files and folders combined). How do you enforce this?
How would you determine if two files have identical content?
How would you implement this file system in a production environment?
| Approach | Notes |
|---|---|
| Flat HashMap with full-path keys | Simpler to implement for basic add/get; avoids building a tree. However, listing directory contents or enforcing per-directory constraints (max 5 items) requires scanning all keys with a given prefix, which is less efficient and harder to maintain. |
| Trie (explicit tree nodes) | Naturally models the hierarchy; makes listing children and enforcing per-level constraints straightforward. Slightly more complex to implement than a flat map but scales better for deep path queries and listing operations. |
Common mistakes: Not anticipating the tricky duplicate-name test case where the counter wraps the whole filename — e.g., treating file(1).txt as already-taken and not producing file(1)(1).txt.; Candidates who failed did not know what the production follow-up was asking and gave unfocused answers about storage structures and NoSQL without a clear direction.; One candidate completed every coding part correctly but was inexplicably rejected due to a disengaged interviewer, suggesting non-technical factors can also sink outcomes.
Interviewer hints: The interviewer ran specific test cases without announcing them in advance, including the three-add duplicate collision case, then asked 'do you know what these test cases are doing?'; One interviewer explicitly said the tricky part is handling duplicate file names — A becomes A(1) on re-insert.; The production follow-up ('how would you implement this in production?') was asked verbally without requiring code; the interviewer seemed to want a high-level architectural answer but was not clear about what specifically they wanted.
What passers do: Candidates who prepared from prior reports and knew the duplicate-filename test case (add(file.txt), add(file.txt), add(file(1).txt) → file.txt, file(1).txt, file(1)(1).txt) handled it quickly and correctly.; Using a Trie (prefix tree) structure was specifically mentioned as a clean way to implement the directory hierarchy; candidates who used it moved through the problem fast.; Answering the 'identical file content' follow-up with file hashing (SHA-256 / MD5) led to passing the phone screen.; Finishing the core coding quickly (one candidate finished all parts in 45 minutes) left time for discussion rather than pressure.