K closest points to origin
Problem Given points on a plane and k, return the k points closest to the origin (any order).
Input / Output
- Input: int[][] points, int k. Output: k closest points.
Constraints
- Up to 10^4 points; compare SQUARED distances (no sqrt — avoids float issues).
Example
- points = [[1,3],[-2,2]], k = 1 → [[-2,2]] (4+4=8 < 1+9=10).
asked …