Problem
Given a list of points points, where each point is [x, y], and a number k, return the k points closest to the origin (0, 0) by straight-line distance. You can return them in any order.
Example 1
- Input
- points = [[1, 3], [-2, 2]], k = 1
- Output
- [[-2, 2]]
Example 2
- Input
- points = [[3, 3], [5, -1], [-2, 4]], k = 2
- Output
- [[3, 3], [-2, 4]]
Constraints
1 <= k <= points.length <= 10^4-10^4 <= x, y <= 10^4The tests are chosen so the answer is unique.