Booking.com Interview Question

I was asked to solve a programming problem.