class Solution:
def findJudge(self, N: int, trust: List[List[int]]) -> int:
if N==1:
return 1
d1={}
d2={}
for i, j in trust:
if j in d1:
d1[j]+=1
else:
d1[j]=1
if i in d2:
d2[i]+=1
else:
d2[i]=1
for i,j in d1.items():
if j==N-1:
if i not in d2:
return i
return -1
Download Find The Town Judge.pyLeetcode 997 Find The Town Judge problem solution in python3 with explanation. This is the best place to expand your knowledge and get prepared for your next interview.
Feedback is the most important part of any website.
If you have any query, suggestion or feedback, Please feel free to contact us.