Booking.com interview question

It was a pretty common moderately difficult leetcode problem for the technical interview