Pregunta de entrevista de Oracle

Different ways to solve the problem