We started with quick self-introductions on both sides — no deep-dive project questions. Then came two coding questions built around a single scenario; the questions and the amount of code involved weren't trivial. At the end I got to ask the interviewer some questions.
Q1: Given the invoice ID inside a payment's memo, find the matching invoice in the invoice list and output the result.
My approach: parse the payment string to pull out the ID, amount, and memo, then extract the target invoice ID from the memo. Build a map from invoice ID to invoice details, then look up the match. If found, output the payment info; otherwise say it wasn't found. Handle edge cases like extra whitespace. Time complexity O(n).
Q2: Extend the matching logic to support two modes — memo matching and amount matching. If the memo is in the standard format, match by invoice ID; otherwise match by payment amount (and if multiple invoices share the same amount, pick the one with the earliest due date). This one built directly on Q1.
My approach: 1) if the memo contains "Paying off:", use the same memo-matching logic as Q1; otherwise fall into amount-based matching. 2) Iterate over all invoices and filter to the ones where amount == paymentAmount; if nothing matches, output something like "cannot find matching invoice for amount ...". 3) Sort the matches by dueDate (or just iterate through them) to find the earliest one.
No real problems — I got all the code written out. Good thing I'd more or less already rehearsed this, since I'd done a mock interview beforehand, so the interviewer and I were pretty in sync and it went smoothly. My code comments were detailed, and the interviewer kept giving hints the whole way through, even though I wasn't feeling too confident inside (TT). None of the overseas TikTok/Google/Microsoft/Amazon interviews I'd done before had asked anything quite like this.
Discussion
Loading comments…