Pregunta de entrevista de Booking.com

HackerRank test, Leetcode easy/medium difficulty.