Pregunta de entrevista de Oracle

Coding challenge was hard and difficult to Crack