Pregunta de entrevista de Accenture

pseudo code based on coding