Booking.com interview question

I was asked to solve a programming problem.