255. K Closest Points to Origin
Medium · Heap
Given an array of `points` and integer `k`, return the `k` closest points to the origin (0,0). Distance is Euclidean. Order does not matter.
Examples
Example 1 Input: points=[[1,3],[-2,2]], k=1 Output: [[-2,2]] Explanation: Distance of [1,3] is √10, distance of [-2,2] is √8
Constraints
- 1 ≤ k ≤ n ≤ 10⁴