提交:O(N)
class Solution: def destCity(self, paths: List[List[str]]) -> str: dic = {} for i,v in paths: dic[i] = v tmp = paths[0][1] while tmp in dic: tmp = dic[tmp] return tmp
2023-10-21 20:14:10
提交:O(N)
class Solution: def destCity(self, paths: List[List[str]]) -> str: dic = {} for i,v in paths: dic[i] = v tmp = paths[0][1] while tmp in dic: tmp = dic[tmp] return tmp