class FileSystem:
The round: one problem built up in three parts, reported in four phone screens and four onsites between May 2025 and June 2026 (a ninth report does not say which round). The original report, a phone screen, describes an interviewer who wrote and ran his own test cases without saying which rule each one checked, and questioned the candidate's test results several times before conceding he had made the mistake himself. Another early candidate says the question was so new that the interviewer worked out the requirements from his own test data during the call. One onsite candidate called it very simple and finished in 45 minutes; a reply under that report guesses it is the easiest in Harvey's bank. Outcomes vary: passers and rejections both appear, and two candidates who solved every part were still turned down.
What the reports give. The original report names two operations, addFile(String path) and getFile(String path): adding "path/to/somewhere/file.txt" stores the file, getFile("path/to/somewhere") returns file.txt, and getFile("path/to") returns the folder somewhere. A later onsite report describes the same round as "create file/folder and list files under folder". Our setup — ask your interviewer: the Python names below, add_folder for "create folder", relative paths separated by "/", add_file creating any missing folders on its path (the original example only ever calls addFile, yet path/to then holds somewhere), and get_file on a folder returning the names in it.
class FileSystem:
def __init__(self): ...
def add_file(self, path: str): ... # store a file; create missing folders on the way
def add_folder(self, path: str): ... # create a folder
def get_file(self, path: str): ... # a folder path -> the names in that folder
The tests compare each listing as a sorted list of names, so any collection in any order passes. They never check what add_file returns, and a refused add may raise, return False or print: the tests only check that the folder did not change.
Part 1 — Add files, list a folder
add_file(path) stores a file, creating every missing folder on its path.add_folder(path) creates a folder. The tests create one folder inside a folder that already exists.get_file(path) on a folder returns the names directly inside it, files and folders alike. An empty folder returns nothing.fs = FileSystem()
fs.add_file("path/to/somewhere/file.txt")
fs.get_file("path/to/somewhere") # file.txt
fs.get_file("path/to") # somewhere
Walk the path only as far as folders already exist. The deepest existing folder is the only existing folder that would gain a new entry; every folder created below it is new and empty. Whether a full folder also blocks adds inside one of its existing subfolders is not reported; ask. If the add puts a new key there (a new folder or a new file name), refuse when it already holds 5, and check before creating anything so a refused add leaves nothing behind. The original poster simply counted the keys.
Probe the folder for the first free name: split the name being added at its last dot and try stem(1).ext, stem(2).ext, ... A third file.txt becomes file(2).txt; adding file(1).txt when it already exists gives file(1)(1).txt, which is the interviewer's own test. One onsite report writes the copy as a (1).txt, with a space; ask which.
One candidate answered with file hashing (SHA-256 or MD5) and passed the phone screen. In the original report the candidate suggested a separate service for content lookup and the interviewer said it made sense. Comparing sizes first is a cheap filter (our addition).
Standard explanation — no candidate report records what the interviewer accepted here.
No report records an answer that landed: the one candidate asked could not tell what was wanted. A standard answer: file bytes in blob storage keyed by a content hash, the folder tree as rows of (id, parent id, name, kind) in a database, and the entry limit and unique names enforced per parent.
Nine first-hand reports from May 2025 to June 2026: four phone screens and four onsites, plus one that does not say which round. The original report, a phone screen, gives the API, the 5-entry limit, the rename rule and the interviewer's own test; another phone-screen candidate says the question was identical to it. One early candidate remembers adding and deleting files under a path with a per-folder file limit, and says the question was so new that the interviewer worked out its requirements from his own test data during the call. One onsite report calls it the vault question.
In the original report the interviewer wrote and ran test cases without saying what they checked, then asked the candidate whether he knew what they were testing; the candidate's code gave the right answers. The interviewer also questioned the candidate's test results several times, then said he had made the mistake himself. That candidate failed and could not tell what the production follow-up wanted.
Outcomes: one candidate answered the same-content follow-up with SHA-256 or MD5 hashing and passed the phone screen; another passed the onsite with no detail. One candidate solved every part with a trie and was rejected without a reason, saying the interviewer was busy with other work throughout. One onsite candidate finished in 45 minutes, got good feedback with nothing negative, and lost the offer to a candidate whose background fit better. Two rejected candidates blame the system design round.
The round: one problem built up in three parts, reported in four phone screens and four onsites between May 2025 and June 2026 (a ninth report does not say which round). The original report, a phone screen, describes an interviewer who wrote and ran his own test cases without saying which rule each one checked, and questioned the candidate's test results several times before conceding he had made the mistake himself. Another early candidate says the question was so new that the interviewer worked out the requirements from his own test data during the call. One onsite candidate called it very simple and finished in 45 minutes; a reply under that report guesses it is the easiest in Harvey's bank. Outcomes vary: passers and rejections both appear, and two candidates who solved every part were still turned down.
What the reports give. The original report names two operations, addFile(String path) and getFile(String path): adding "path/to/somewhere/file.txt" stores the file, getFile("path/to/somewhere") returns file.txt, and getFile("path/to") returns the folder somewhere. A later onsite report describes the same round as "create file/folder and list files under folder". Our setup — ask your interviewer: the Python names below, add_folder for "create folder", relative paths separated by "/", add_file creating any missing folders on its path (the original example only ever calls addFile, yet path/to then holds somewhere), and get_file on a folder returning the names in it.
class FileSystem:
def __init__(self): ...
def add_file(self, path: str): ... # store a file; create missing folders on the way
def add_folder(self, path: str): ... # create a folder
def get_file(self, path: str): ... # a folder path -> the names in that folder
The tests compare each listing as a sorted list of names, so any collection in any order passes. They never check what add_file returns, and a refused add may raise, return False or print: the tests only check that the folder did not change.
Part 1 — Add files, list a folder
add_file(path) stores a file, creating every missing folder on its path.add_folder(path) creates a folder. The tests create one folder inside a folder that already exists.get_file(path) on a folder returns the names directly inside it, files and folders alike. An empty folder returns nothing.fs = FileSystem()
fs.add_file("path/to/somewhere/file.txt")
fs.get_file("path/to/somewhere") # file.txt
fs.get_file("path/to") # somewhere
Part 2 — Five entries per folder
Part 3 — Duplicate names
fs.add_file("v/file.txt") # v: file.txt
fs.add_file("v/file.txt") # v: file.txt, file(1).txt
fs.add_file("v/file(1).txt") # v: file.txt, file(1).txt, file(1)(1).txt
Each folder can hold at most 5 entries, files and folders together, and a full folder refuses even a new path through it. How do you enforce this?
If a file name already exists in its folder, rename the new file the way a desktop does: file.txt, file(1).txt, file(2).txt. What do file.txt, file.txt, then file(1).txt become?
How do you tell whether two files have the same content when their metadata differs?
How would you run this in production?
| Approach | Notes |
|---|---|
| Flat HashMap with full-path keys | A reply under the original report notes it is simpler if you never list a folder. Reading one file by full path is a single lookup, but listing a folder or counting its entries scans every key for the prefix. |
| Trie (explicit tree nodes) | Models the hierarchy, so listing a folder and counting its entries are direct. One candidate used a trie, solved every part and was still rejected; no report ties the structure to the outcome. |
Common mistakes: One candidate, who failed, could not tell what the production follow-up wanted; his answer about storage layout, NoSQL and keeping addresses in a database did not seem to land.; One candidate solved every part with a trie and was rejected without a reason; the candidate says the interviewer was busy with other work throughout.; Not reported, a code pitfall: numbering from a stripped base name turns file(1).txt into file(2).txt, where the interviewer's test expects file(1)(1).txt.
Interviewer hints: In the original report the interviewer ran his own test cases without saying which rule each checked, including file.txt, file.txt, then file(1).txt, and then asked whether the candidate knew what those tests were doing.; The same interviewer questioned the candidate's test results several times, then found the mistake was his own.; In an early report the question was so new that the interviewer worked out its requirements from his own test data during the call.; The same-content and production questions were asked with no code.
What passers do: One candidate prepared from an earlier report, answered the same-content follow-up with file hashing (SHA-256 or MD5), and passed the phone screen.; Another candidate passed the onsite; that report names the question and gives no other detail.
If you have had this round, tell us how close this page was. It is how we keep the pages accurate.
Send them this page. It is free to read, no account needed.
What you just read — canonical solution, follow-up arc, what passing candidates actually did — exists for all 10 Harvey AI questions, refreshed monthly from new candidate reports.