Domanda di colloquio di Droom

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