Skip to content

Instantly share code, notes, and snippets.

View MrShafqatNadeem's full-sized avatar

Shafqat Nadeem MrShafqatNadeem

View GitHub Profile
@ahmet-cetinkaya
ahmet-cetinkaya / findJudge.js
Created January 27, 2021 15:24
Leetcode Solution - 997. Find the Town Judge
const findJudge = (N, trust) => {
const p = new Array(N + 1).fill(0);
for (let [i, j] of trust) {
--p[i];
++p[j];
}
for (let i = 1; i < p.length; ++i) if (p[i] === N - 1) return i;
return -1;
};