Booking.com Interview Question

Two programming problems, probably around easy-medium on hackerrank. O notation and reasoning for the solutions you give.