Find the Town Judge LeetCode solution in C++

1
class Solution {
2
public:
3
int findJudge(int N, vector<vector<int>> &trust) {
4
vector<int> Trusted(N + 1, 0);
5
for (auto person : trust) {
6
Trusted[person[0]]--;
7
Trusted[person[1]]++;
8
}
9
for (int i = 1; i <= N; i++) {
10
if (Trusted[i] == N - 1) return i;
11
}
12
return -1;
13
}
14
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0