Harvey Software Engineer Interview Experience — A File System Question and a Hard-to-Follow Interviewer
Company: Harvey
Role: Software Engineer
Round: Technical Screen
Seniority: General
Company: Harvey
Role: Software Engineer
Round: Technical Screen
Seniority: General
The file system question from 1point3acres. The writeup is here: a question that hasn't shown up on the forum before, basically a file system where you implement two functions:
addFile(String path) — given a string like "path/to/somewhere/file.txt", store this file
getFile(String path) — input "path/to/somewhere" returns file.text, input "path/to" returns the "somewhere" folder
There wasn't really a self-introduction at the start, we just jumped straight in. The interviewer was American but genuinely struggled to communicate clearly. He explained the problem once and I didn't get it, so I just read it myself — his explanation was very terse. I just added a dict of dict and passed it down layer by layer, and that was it.
Follow-up 1: each level can have at most 5 things (including folders and files) — meaning once the current level's key count goes over 5, you can't add a new folder or file, even if it's just a brand new path. Just brute-force count the keys.
Follow-up 2: if there are duplicate names, you need to handle it like a computer's file system does — file.txt, file(1).txt, file(2).txt. Just parse it (split around the "."), then maintain a counter that increments. One of the test cases was add(file.txt), add(file.txt), add(file(1).txt), and the expected output was file.txt, file(1).txt, file(1)(1).txt. The interviewer himself struggled with this test case for a while, and after running it he asked me if I knew what these test cases were actually testing. This requirement was never stated the whole time — he didn't explain it when he was writing the test either (how was I supposed to know what he wanted?). But my answer turned out to be correct.
Follow-up (no code needed): what if this went into production? How would you actually implement it in real code? I had no idea what he was asking. I explained storage structure, NoSQL, storing addresses in a DB, that kind of thing, and he didn't seem to follow. Finally he asked how you'd tell whether two files have the same content. Metadata would all be different, so I ended up saying something about a separate service to do content lookup — honestly I didn't even know what I was saying at that point... He said it made sense and then time was up.
He also asked, as a follow-up, how to tell whether two files are identical. Thanks to the writeup I'd prepared for this one — the answer is file hashing, like sha256 and md5.