Skip to content

Commit 133bc38

Browse files
committed
solved: 997. Find the Town Judge
Signed-off-by: rajput-hemant <[email protected]>
1 parent 6accd6d commit 133bc38

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
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+
count = [0] * (n + 1)
4+
for i, j in trust:
5+
count[i] -= 1
6+
count[j] += 1
7+
8+
for i in range(1, n + 1):
9+
if count[i] == n - 1:
10+
return i
11+
12+
return -1

0 commit comments

Comments
 (0)