Solution Review: Closest Pair of Points

This review discusses the solution of the Closest Pair of Points challenge in detail.

Solution # 1

A naive solution to this approach is to compute all possible distances between each pair of points, while keeping a minimum distance, and return the minimum distance at the end.

Time Complexity

This brute force solution runs in O(n2)O(n^2) since we are calculating the distance of one point with every other point to find the minimum

Solution # 2 (Efficient)

We can find out the closest pair of points using a divide and conquer approach as follows:

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.