Format: CoderPad, pick your own language (I used Python), 60 minutes. The first 10 minutes or so were mutual introductions, and then we went straight into coding. The interviewer only gave me the problem description. There was no starter code and no test code. How to design the class and how to write the tests was all on me.
The problem: implement a File Storage. The problem description (written from memory, so the details may be slightly off):
Implement an file storage service.
class FileStorage
- upload_file(file_name: str, file_content: bytes) -> str
Stores the file and returns a unique file_id.
If a file with the same name already exists, a suffix is added to the
new file's name.
- get_file(file_id: str) -> bytes
Returns the file content. Raises an error if the file doesn't exist.
- delete_file(file_id: str) -> bool
Deletes the file. Returns True if it was deleted, False if it didn't exist.
- get_all_files() -> list[dict]
Returns metadata for all stored files:
[{"file_id": ..., "file_name": ..., "file_size": ..., "upload_timestamp": ...}]
Overall feeling: looking back, the problem is not hard, but I had forgotten a lot of syntax details, and with no test code at all I was panicking at the start and wasted a lot of time. I finished writing the code in the last minute of the interview, but I did not get to test it. I feel like I'm toast. Waiting for the result.
Discussion
Loading comments…