class Solution:
def findJudge(self, N: int, trust: 'List[List[int]]') -> int:
if N==1 and len(trust)==0:
return 1
s = list(range(1,N+1))
d = {}
for t in range(len(trust)):
a1 = trust[t][0]
a2 = trust[t][1]
if a1 in s:
s.remove(a1)
if a2 in d.keys():
d.update({a2:d[a2]+1})
else:
d.update({a2:1})
if len(s)==1 and s[0] in d.keys() and d[s[0]]==N-1:
return s[0]
else:
return -1