GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 997_Find_The_Town_Judge (#9) · pengaoao/leetcode@eaaab36

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • python
    • 997_Find_The_Town_Judge.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎python/997_Find_The_Town_Judge.py‎

Copy file name to clipboard
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Solution:
2+
def findJudge(self, N: int, trust: List[List[int]]) -> int:
3+
if N==1:
4+
return 1
5+
d1={}
6+
d2={}
7+
for i, j in trust:
8+
if j in d1:
9+
d1[j]+=1
10+
else:
11+
d1[j]=1
12+
if i in d2:
13+
d2[i]+=1
14+
else:
15+
d2[i]=1
16+
for i,j in d1.items():
17+
if j==N-1:
18+
if i not in d2:
19+
return i
20+
return -1
21+

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.