Booking.com interview question

A recursive problem solution