In a town of n people, the judge is trusted by everyone else and trusts nobody. Return the label of the judge, or -1 if no judge exists. Pattern focus: Graph Degree Analysis. The judge is the node with indegree n-1 and outdegree 0.
n = number of people, trust = directed trust relationships [a, b]
label of the judge, or -1 if none exists
Example 1:
Input:
n = 2 trust = [[1,2]]
Output:
2
Explanation:
Person 2 is trusted by 1 and trusts nobody.
Example 2:
Input:
n = 3 trust = [[1,3],[2,3]]
Output:
3
Explanation:
Person 3 is trusted by everyone else.