Hardest problem ever

You have an integer array A of size N. Find closest pair of numbers in an array and print their difference.

Sort the array using any algorithm like quick sort or Merge sort. and then

		min = arr[1]-arr[0]

		for i in 2 to N-1

			min = min<(arr[i]-arr[i-1])?min:(arr[i]-arr[i-1]);

Complexity : O(NlogN + N) = O(NlogN)

@avd_0 Why are you posting your solutions to different-different questions on discuss group. If one wants to see solutions he/she can check out editorials or all submissions. Don’t spam the group with your solutions .
Plus the questions you are posting are not that tough that you are posting your answer for one to understand and get the solution.

7 Likes