Pregunta de entrevista de Oracle

I had to complete Closest numbers hackerrank exercise