Pregunta de entrevista de DP World

4th question of leetcode contest