I got unlucky — I'd spent a long time studying the bank system and file system problems, and then a brand new question showed up.
The question was to design a recipe storage system. Each recipe has a name, a list of ingredients, and a list of steps.
First question (I didn't even pass this one, so this is all I have): design the four CRUD methods for this system.
The main thing was that the test cases threw a ton of edge cases at you. Here's what I still remember:
- When adding, it's case-insensitive (the same name in different cases counts as one recipe), but when you store it and when you Get it, you need to show the originally submitted name. Storage is supposed to use an auto-incrementing ID, but the ID given in Read/Update/Delete is a string, so you need to substring it out — e.g. Get("recipe2"). For Update: if the ID is different, you can't update. If the ID is the same but the name only differs in case, you can update. If the ID is the same but the name is actually different, you can't update.
What was rough is that none of these rules were in the problem statement — they were all hidden in the test cases, and you had to slowly dig them out yourself...
Not sure if it's because I hadn't been grinding problems for a while or if the question was just really hard. Time to go grind properly.
Discussion
Loading comments…