• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Uriel's Corner

            Research Associate @ Harvard University / Research Interests: Computer Vision, Biomedical Image Analysis, Machine Learning
            posts - 0, comments - 50, trackbacks - 0, articles - 594

            Firstly process the edge list and save as a node dict. Then start from node 0, DFS the whole tree. If current node is not root node and (current node has an apple or children nodes have apples), then the resultant time need to +2 (from parent node to current node and back).


             1 #1443
             2 #Runtime: 541 ms (Beats 100%)
             3 #Memory: 54.5 MB (Beats 61.11%)
             4 
             5 class Solution(object):
             6     def minTime(self, n, edges, hasApple):
             7         """
             8         :type n: int
             9         :type edges: List[List[int]]
            10         :type hasApple: List[bool]
            11         :rtype: int
            12         """
            13         nodes = defaultdict(list)
            14         for x, y in edges:
            15             nodes[x].append(y)
            16             nodes[y].append(x)
            17 
            18         def DFS(r, p):
            19             res = 0
            20             for son in nodes[r]:
            21                 if son != p:
            22                     res += DFS(son, r)
            23             if r and (res or hasApple[r]):
            24                 return res + 2
            25             return res
            26 
            27         return DFS(0, -1)
            久久综合鬼色88久久精品综合自在自线噜噜 | 久久精品亚洲精品国产色婷| 久久久久这里只有精品| 久久亚洲视频| 国产香蕉久久精品综合网| 久久精品国产99国产精偷| 欧美麻豆久久久久久中文| 久久精品国产亚洲av高清漫画| 久久99精品久久久久久| 久久久久亚洲av成人无码电影| 精品国产日韩久久亚洲| 久久精品国产精品青草app| 亚洲伊人久久综合中文成人网| 青青青青久久精品国产h| 色综合久久无码中文字幕| 久久精品女人天堂AV麻| 18岁日韩内射颜射午夜久久成人 | 久久精品成人国产午夜| 午夜视频久久久久一区 | 精产国品久久一二三产区区别| 欧洲国产伦久久久久久久| 精品熟女少妇a∨免费久久| 午夜精品久久久久久99热| 久久婷婷久久一区二区三区| 久久综合亚洲色HEZYO社区| 久久久久久亚洲精品不卡| 伊人丁香狠狠色综合久久| 精品综合久久久久久888蜜芽| 久久婷婷色综合一区二区| 欧美精品九九99久久在观看| 久久精品无码一区二区三区免费| 久久精品国产91久久综合麻豆自制| 午夜人妻久久久久久久久| 久久免费看黄a级毛片| 亚洲美日韩Av中文字幕无码久久久妻妇 | 人妻无码久久精品| 久久精品无码一区二区日韩AV| 99久久久精品| 韩国三级中文字幕hd久久精品| 久久精品亚洲乱码伦伦中文 | 国产精品成人精品久久久|