Booking.com Coding Interview: Unpaid Bookings Report

Based on questions reported for Booking.com interviews

The interviewer opens

Hi, and thanks for joining. Welcome to your interview for the software engineer role at Booking.com. We'll work through one coding problem together, and I'd like you to think out loud as you code. If you need to step out or take a break, you can pause the interview any time with the Pause button at the top right.

The problem is about building a report of unpaid bookings from raw payment logs, the kind of reconciliation work that matters when money moves through a travel platform. It's in the Problem tab on the right, so please read it through, take your time, and ask me any questions before you start.

The problem

Payment operations needs a list of bookings that are not yet fully paid, built from raw JSON log lines.

  • log_lines: a list of strings. Each is one JSON object, either {"type":"booking","booking_id":"B1","amount":30000} (amount due, in cents) or {"type":"payment","booking_id":"B1","amount":10000} (amount paid, in cents).

Lines can appear in any order. Each booking_id has exactly one booking line, and every payment refers to a booking present in the log. A booking's outstanding amount is its amount due minus the sum of its payments. Return one {booking_id, outstanding} record for each booking whose outstanding amount is greater than 0, sorted by booking_id ascending (string order).

Example: booking B1 30000, payment B1 10000, booking B2 5000, payment B2 5000, payment B1 5000 → [{"booking_id":"B1","outstanding":15000}]

Up to 10^5 lines.