This commit is contained in:
parent
7eb3891f7a
commit
057ada7c64
1 changed files with 19 additions and 0 deletions
19
medium/find_champion_ii.py
Normal file
19
medium/find_champion_ii.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# https://leetcode.com/problems/find-champion-ii/
|
||||
from typing import List
|
||||
|
||||
|
||||
class Solution:
|
||||
def findChampion(self, n: int, edges: List[List[int]]) -> int:
|
||||
lose_team = [False] * n
|
||||
for [_, b] in edges:
|
||||
lose_team[b] = True
|
||||
champ = -1
|
||||
for i in range(len(lose_team)):
|
||||
if lose_team[i] == False:
|
||||
if champ != -1:
|
||||
champ = -1
|
||||
break
|
||||
else:
|
||||
champ = i
|
||||
return champ
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue