Pregunta de entrevista de IBM

There was a coding question to be solved at first.