Solved the 1d version of closest pair