Pregunta de entrevista de F5

Solve the following coding question