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!
Select
Add answer anonymously...
Dhoot Transmission Technical Trainee Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits