• <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成人出白浆无码国产| 精品久久久久国产免费| 午夜不卡久久精品无码免费 | 国产精品久久新婚兰兰| 日产精品久久久一区二区| 一本大道加勒比久久综合| 伊人久久无码精品中文字幕| 国产精品久久国产精品99盘| 国内高清久久久久久| 国产成人精品免费久久久久| 看全色黄大色大片免费久久久| 午夜精品久久久久久中宇| 2021国产精品午夜久久| 色悠久久久久久久综合网 | 久久久久久久久66精品片| 久久久久国产精品熟女影院| 久久无码一区二区三区少妇| 精品久久久久久久无码| 亚洲精品第一综合99久久| 久久AAAA片一区二区| 国产精品久久成人影院| 亚洲愉拍99热成人精品热久久| 深夜久久AAAAA级毛片免费看| 91精品国产综合久久精品| 精品久久久久久中文字幕大豆网| 色婷婷久久久SWAG精品| 久久成人国产精品一区二区| 97久久综合精品久久久综合| 久久久久久久亚洲Av无码| 久久综合亚洲欧美成人| 久久这里只有精品18| 久久精品国产亚洲AV电影| 亚洲精品无码久久久久sm| 无码专区久久综合久中文字幕| 中文字幕热久久久久久久| 一本一本久久A久久综合精品 | 久久水蜜桃亚洲av无码精品麻豆| 久久中文精品无码中文字幕| 亚洲AV无码久久寂寞少妇| 久久精品国产亚洲av麻豆蜜芽| 久久精品国产久精国产果冻传媒 |