I just finished the Airbnb online assessment. I'm an experienced hire switching jobs, not a new grad. The problem is like transferring money between bank accounts, split into four levels, 90 minutes total. It's the same one that was in earlier interview reports on the forum.
Level 1 is implementing create and add credit.
Level 2 is instant transfer, and outputting the top k.
Level 3 is being able to schedule a transfer for a future time, and cancel a future transfer.
Level 4 is merging two accounts and outputting the account balance at every point in history.
Levels 1 and 2 are pretty straightforward. First I wrote a small Workspace class with the most basic add/subtract credit functions. Then WorkspaceManagement keeps a hashmap of id -> workspace. Create, add credit and transfer just call the functions in the small class. For the top k, I iterate over the hashmap, put credit and id into a temporary array, sort it, and output k. Handle the edge cases.
For level 3, I added a transaction hashmap to store the transfers, and then wrote a function that executes all transfers scheduled before the current time, a do-transfer-before function. The idea is the same as before: iterate over the transactions, check the timestamp, and finish every transfer before that time. Every public function from before has to call it. Cancel is basically just looking up the id.
The first part of level 4 is deleting the second account and adding its credit to the first account, then canceling all the transactions related to the second account. I got stuck for a bit on whether to run do-transfer-before first or do the cancel first. I ran the tests and found that it has to run first.
I ran out of time for the second part.
Discussion
Loading comments…