Booking.com Interview Question

Coding challenge with two easy two hard wuestions