๐ WAYPOINT LESSON
Closest Pair
โญโญโญ advancedโณ 30 min read๐ Lesson 179 of 281
Sort by x, split, solve halves, and sweep a y-sorted strip โ the strip scan is O(1) amortized per point.
Divide, conquer, and the strip
After solving both halves, only points within delta of the split line matter. Sorted by y, each point has at most 7 neighbors worth checking โ a packing argument, not luck. All distances stay SQUARED: comparisons exact, sqrt only at the very end (or never, if the answer is squared).
โก Now practice
Ready to CodeGeometry SuiteHull areas at 2e5 points, integer point-in-polygon under load, and closest pair at 1e5 points.
3 challenges ยท ยท ~110 min