Find the Town Judge

Easy · Graphs · about 10 minutes

Asked at Amazon, Google, Meta, Microsoft.

In a town of n people (1..n), trust[i] = [a, b] means a trusts b. The town judge trusts nobody and is trusted by everyone else. Return the judge's label, or -1.

Related guides