Pregunta de entrevista de Infosys

Coding question simply asked to solve