※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.229.37.69 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1732633257.A.1AD.html
三天不刷提
便絕面目可蹭
不過我原本就長的ˊ醜
沒差
def findChampion(self, n: int, edges: List[List[int]]) -> int:
indeg = [0 for _ in range(n)]
for e in edges:
indeg[e[1]] += 1
ans = []
for i, deg in enumerate(indeg):
if deg == 0:
ans.append(i)
return ans[0] if len(ans)==1 else -1
--