bumpsoo 2024-11-26 22:46:31 +09:00
parent 7eb3891f7a
commit 057ada7c64

View 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