• <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)
            亚洲精品高清国产一线久久| 久久精品国产影库免费看| 亚洲欧美一级久久精品| 狠狠综合久久AV一区二区三区| 日韩精品久久久久久久电影蜜臀| 久久最近最新中文字幕大全| 欧美亚洲日本久久精品| 国产成人精品白浆久久69| 亚洲人成无码www久久久| 久久久久久久人妻无码中文字幕爆| 国产精品欧美亚洲韩国日本久久| 亚洲综合伊人久久综合| 伊人热人久久中文字幕| 久久精品国产亚洲AV无码麻豆| 亚洲婷婷国产精品电影人久久| 91精品国产乱码久久久久久| 亚洲?V乱码久久精品蜜桃| 亚洲精品高清久久| 精品熟女少妇a∨免费久久| 要久久爱在线免费观看| 久久精品国产福利国产琪琪| 99久久精品日本一区二区免费| 久久久久高潮综合影院| 亚洲AV伊人久久青青草原| 国产AV影片久久久久久| 欧美亚洲国产精品久久蜜芽| 国产精品禁18久久久夂久| 午夜精品久久久久久毛片| 精品久久久中文字幕人妻| 亚洲另类欧美综合久久图片区| 久久精品99无色码中文字幕| 国内精品久久久久国产盗摄| 香港aa三级久久三级| 国产三级精品久久| 国产精品免费久久久久久久久| 国产精品亚洲综合专区片高清久久久| 久久久久AV综合网成人| 久久精品国产半推半就| 国产激情久久久久影院老熟女免费 | 伊人久久大香线蕉AV色婷婷色| 亚洲午夜福利精品久久|