System Design: Three-day donations. Specifically, you build a donation entry point for users, where the user submits their personal info plus how much money they want to donate to different organizations, and the problem gives you the assumption that you're only responsible for sending the money to the company's account. During the discussion the interviewer strongly suggested making it async, but personally I felt that if the payment only takes a few seconds, it's not like you can't just let the user wait a bit. Also pay attention to idempotency.
Debug: round-robin.
The first bug was a typo — "AVAILABLE" was misspelled as "AVALABL".
The second bug was using a local variable to track the currently served node, which should be changed to a private variable instead.
The third bug was that if no available node is found, you need to use a while loop to search all the way around.
The fourth was a wrong test case — the original test case expected a match against an unavailable node, which isn't correct.
The follow-up was to implement consistent hashing and compare the two approaches.
Code craft: Dasher Pay, exactly the same as every other write-up out there.
HM: I think this was the round that went the worst. I didn't prepare and just chatted casually, but as we talked I realized I'd actually forgotten some of my past project details... haha
Discussion
Loading comments…