Pergunta de entrevista da empresa Booking.com

Sorting algorithm as the question