Closest Pair of Points Problem Statement
Given an array containing 'N' points in a plane, your task is to find the distance between the closest pair of points.
Explanation:
The distance between two points, (x1, y1) and (x2, y2), is calculated using the formula: [(x1 - x2) ^ 2] + [(y1 - y2) ^ 2].
Input:
N
x1 y1
x2 y2
...
xN yN
Output:
The smallest distance between the closest pair of points among the given 'N' points.
Example:
Input:
4
0 0
1 1
-1 -1
2 2
Output:
2
Constraints:
- 2 ≤ 'N' ≤ 105
- -105 ≤ 'x' ≤ 105
- -105 ≤ 'y' ≤ 105
- Time Limit: 1 second
Note:
You do not need to print anything; it has already been taken care of. Simply implement the provided function.
Be the first one to answer
Add answer anonymously...
Top Snapdeal Software Developer interview questions & answers
Popular interview questions of Software Developer
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