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

Method count

javascript/2013-detect-squares.js:20–33  ·  view source on GitHub ↗
(point, { points } = this, score = 0)

Source from the content-addressed store, hash-verified

18 }
19
20 count (point, { points } = this, score = 0) {
21 const [ x1, y1 ] = point;
22
23 for (const [ x2, y2 ] of points) {/* Time O(N) */
24 const isSame = (Math.abs(x2 - x1) === Math.abs(y2 - y1));
25 const isEqual = ((x1 === x2) || (y1 === y2));
26 const canSkip = (!isSame || isEqual);
27 if (canSkip) continue;
28
29 score += this.getScore(x1, y1, x2, y2);
30 }
31
32 return score;
33 };
34
35 getKey (x, y) {
36 return `${x},${y}`;

Callers

nothing calls this directly

Calls 1

getScoreMethod · 0.95

Tested by

no test coverage detected