(points, K)
| 6 | * @return {number[][]} |
| 7 | */ |
| 8 | var kClosest = function (points, K) { |
| 9 | const distance = ([x, y]) => x * x + y * y; |
| 10 | |
| 11 | points.sort((a, b) => distance(a) - distance(b)); |
| 12 | |
| 13 | return points.slice(0, K); |
| 14 | }; |
| 15 | |
| 16 | /** |
| 17 | * https://leetcode.com/problems/k-closest-points-to-origin/ |
nothing calls this directly
no test coverage detected