Hackerrank – Closest Numbers

Problem Statement
A description of the problem can be found on Hackerrank.

Solution
Sort the input array ascending. For element at index i do difference with element at index i+1. Find the minimum difference. Check all elements and find all pair that have this minimum difference. Print found elements ascending.

I created solution in:

All solutions are also available on my GitHub.

Java

JavaScript

Scala

Ruby