Oracle interview question

I had to complete Closest numbers hackerrank exercise