← Booking.com Interview Insights
My first instinct was to reach for a nested loop and I'm glad I caught myself before saying it out loud.
Start by clarifying the input format and edge cases, then propose an efficient aggregation using a hash map to sum payments per booking. After computing totals, compare each booking's total paid against its amount due to assign the correct status, and finally discuss trade-offs like time/space complexity and handling of missing or invalid data.
Pro tip: Mention that you would handle floating-point precision carefully (e.g., using integers for cents or a tolerance) to avoid misclassification due to rounding errors. Also, proactively discuss how to handle bookings with no payments and payments referencing non-existent bookings.
Ask about input types, expected output format, and how to handle edge cases like missing bookings, duplicate payments, zero amounts, and floating-point precision.
Propose using a hash map to accumulate total paid per booking ID by iterating through the payments list once. Discuss time and space complexity.
Iterate through the bookings list, compute the difference between total paid and amount due, and assign status: PAID if equal, UNPAID if zero paid, UNDERPAID if less, OVERPAID if greater.
Explain how to handle payments for unknown booking IDs, bookings with no payments, and precision issues (e.g., using integer cents or a tolerance).
Talk about alternative approaches (e.g., sorting, database aggregation), memory usage, and whether to mutate inputs or return a new mapping.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.