class Solution:
def findJudge(self, N: int, trust: List[List[int]]) -> int:
if N == 1:
if trust == []:
return 1
return -1
to = collections.Counter([i[1] for i in trust])
judge = to.most_common(1)[0][0]
trust_by = [False] * (N + 1)
for i, j in trust:
if i == judge:
return -1
if j == judge:
trust_by[i] = True
trust_by[judge] = True
if not all(trust_by[1:]):
return -1
return judge