Join Regular Classroom : Visit ClassroomTech

Coding Questions | The Closest Pair | Codewindow.in

Given an integer array with ‘N’ (2<=N<=1000) points. Find the distance between the closest pair of points.

Input Format:
Input 1: N, the number of points in an array
Input 2: Array of numbers

Output Format:
Return the distance between the closest pair of points.

Example 1:
Input 1: 3
Input 2: {-10,0,11}

Output:
10

Explanation:
In the above example, the distance between -10 and 0 is 10. Distance between -10 and 11 is 21, and between 0 and 11 is 11. So, the distance between the closest pair is 10.

Example 2:
Input 1: 5
Input 2: {10,2,-4,5,29}

Output:
3

Explanation:
In the above example, the distance between 2 and 5 is 3, and between all other points is greater than 3. So, the distance between the closest pair is 3.

Solution:

Coming....
You Missed
Also Checkout