Booking.com interview question

ranking problem