Closest Distance Pair Problem Statement
Given an array containing 'N' points in a 2D plane, determine the minimum distance between the closest pair of points.
Note:
Distance between two points (x1, y1) and (x2, y2) is given by [(x1 - x2) ^ 2] + [(y1 - y2) ^ 2].
Input:
The first line contains a single integer 'N' denoting the number of points.
The next 'N' lines each contain two integers separated by a space, representing the x and y coordinates of the points respectively.
Output:
The output should be the minimum distance between the 'N' points.
Example:
Input:
4
0 0
0 2
2 0
2 2
Output:
4
Constraints:
- 2 <= 'N' <= 105
- -105 <= 'x' <= 105
- -105 <= 'y' <= 105
- Time Limit: 1 sec
Note:
You are not required to print anything; just implement the function.
AnswerBot
1y
The task is to find the distance of the closest points among an array of N points in the plane.
Calculate the distance between each pair of points using the given formula
Keep track of the minimum dista...read more
Help your peers!
Add answer anonymously...
Popular interview questions of Technical Trainee
>
Dhoot Transmission Technical Trainee Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app