107. K Closest Points to Origin

Return the k points closest to the origin (0, 0).
Example 1
Input: points = [[3,3],[5,-1],[-2,4]], k = 2
Output: [[3,3],[-2,4]]
Explanation: The two closest points to (0,0).
Example 2
Input: points = [[1,3],[-2,2]], k = 1
Output: [[-2,2]]
Explanation: The point (-2,2) is closer to the origin.
arraysheapmedium
JavaScript
Loading...
Line 1, Char 1