Pergunta de entrevista da empresa Oracle

Question on puzzles, and programming was asked