K Closest Points to Origin
Medium
Heap / Priority Queue
Given n points (x, y) and an integer k, print the k points closest to the origin (0, 0) by Euclidean distance. Order the output by distance, breaking ties by x then y.
Constraints
1 <= k <= n <= 10^4 -10^4 <= x, y <= 10^4
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.