diff --git a/medium/find_champion_ii.py b/medium/find_champion_ii.py new file mode 100644 index 0000000..7d2e1ad --- /dev/null +++ b/medium/find_champion_ii.py @@ -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 +