Skip to content

Commit dd0ec90

Browse files
authored
Create 0997-find-the-town-judge.py
1 parent daea53c commit dd0ec90

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

python/0997-find-the-town-judge.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def findJudge(self, n: int, trust: List[List[int]]) -> int:
3+
delta = defaultdict(int)
4+
5+
for src, dst in trust:
6+
delta[src] -= 1
7+
delta[dst] += 1
8+
9+
for i in range(1, n + 1):
10+
if delta[i] == n - 1:
11+
return i
12+
return -1

0 commit comments

Comments
 (0)