leetcode-187周赛-5400-旅行终点站

 

提交: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

 

posted @ 2020-05-03 20:46  oldby  阅读(92)  评论(0编辑  收藏  举报