Almost all of these were questions I had already seen in interview experience posts!
Worst sorting algorithm: I talked about enumerating every permutation and checking whether each one is sorted.
Coffee shop: A and B each buy two cups of coffee. What is the probability that A's two cups taste better than B's two cups?
There are 1M user_ids. How do you efficiently check whether an id exists, and add it if it doesn't? How do you balance latency / memory / accuracy? I started by just using an in-memory set, then extended the answer to a Bloom filter + memtable + SSTable.
CSV debug: the main bug was that the string concatenation should be switched to a StringBuilder, because every string concat is O(N), so the whole loop turns into O(N^2). The other bug was an extra comma at the end of every row.
Payment service debug: I talked about idempotency keys. Write to the DB first with status = pending before calling the provider, then update the DB after the provider succeeds or fails. If it is an uncertain failure (for example a timeout), hand it off to a reconciler.
Discussion
Loading comments…