Find the Town Judge LeetCode solution in Python

1
class Solution:
2
def findJudge(self, N: int, trust: List[List[int]]) -> int:
3
Trusted = [0] * (N + 1)
4
for a, b in trust:
5
Trusted[a] -= 1
6
Trusted[b] += 1
7

8
for i in range(1, len(Trusted)):
9
if Trusted[i] == N - 1:
10
return i
11
return -1

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0