. - 力扣(LeetCode) from typing import List class Solution: def destCity(self, paths: List[List[str]]) -> str: # 根据题意只需要找到所有线路的终点不为起点的城市即可 start_city = set() end_city = set() for path in paths: start_city.add(path[0]) end_city.add(path[1]) return list(end_city - start_city)[0]