Pregunta de entrevista de CureMD

the asked to solve a coding