Pregunta de entrevista de Droom

One coding question was given and asked to write algo for that