Booking.com Interview Question

it was related to create a better algorithm for a On2 solution that should be On