We started with mutual self-introductions — no deep dive into past projects. Then came two coding problems based on one scenario; the problem statements and the amount of code weren't small. At the end I got to ask the interviewer some questions.
Q1: Given an invoice ID embedded in a payment memo, match it against 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 matching invoice. If found, output the payment info; if not, print a not-found message. Handle edge cases like extra whitespace. Time complexity O(n).
Q2: Extend the payment-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 (when multiple invoices share the same amount, pick the one with the earliest due date). This 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 for amount == paymentAmount; if there's no match, output "cannot find matching invoice for amount ...". 3) Sort or scan the matches by dueDate and take the earliest one.
No real issues overall — I got all the code written out, thankfully, since I'd done mock interviews beforehand. The back-and-forth with the interviewer felt pretty smooth, no real problems. I commented my code in detail, and the interviewer gave hints throughout. Still, I wasn't totally confident about how it went, honestly. Google, Microsoft, Amazon, and TikTok abroad have never asked me this kind of question before.
Discussion
Loading comments…