MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / distance

Function distance

javascript/0937-k-closest-points-to-origin.js:9–9  ·  view source on GitHub ↗
([x, y])

Source from the content-addressed store, hash-verified

7 */
8var kClosest = function (points, K) {
9 const distance = ([x, y]) => x * x + y * y;
10
11 points.sort((a, b) => distance(a) - distance(b));
12

Callers 1

kClosestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected