class Solution { public: int findJudge(int N, vector<vector<int>>& trust) { vector<unordered_set<int>> vc1(N+1); vector<unordered_set<int>> vc2(N+1); for(auto& m:trust){ vc1[m[0]].insert(m[1]);//出 vc2[m[1]].insert(m[0]);//入 } int res = -1; for(int i=1;i <= N;i++){ if(vc1[i].size()==0&&vc2[i].size()==(N-1)){ res = i; break; } } return res; } };
___用出入度判断