Pregunta de entrevista de Indigo

There was a live coding exercise for a relatively simple problem