8000 Find-The-Town-Judge.cs · qilingit/Leetcode@3fb8381 · GitHub
[go: up one dir, main page]

Skip to content
10000

Commit 3fb8381

Browse files
author
yujie
authored
Find-The-Town-Judge.cs
1 parent 9bddbed commit 3fb8381

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
public class Solution {
2+
public int FindJudge(int N, int[][] trust) {
3+
int[] counter = new int[N+1];
4+
foreach ( int[] person in trust)
5+
{
6+
counter[person[0]]--;
7+
counter[person[1]]++;
8+
}
9+
for(int num=1; num<N+1; num++)
10+
{
11+
if(counter[num] == N-1)
12+
{
13+
return num;
14+
}
15+
}
16+
return -1;
17+
}
18+
}

0 commit comments

Comments
 (0)
0