• <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)
            狠狠人妻久久久久久综合| 久久中文骚妇内射| 伊人久久大香线蕉精品| 99久久国产综合精品女同图片| 久久婷婷人人澡人人| 久久精品18| 日日狠狠久久偷偷色综合0| 日韩欧美亚洲综合久久影院Ds| 91久久成人免费| 久久99国产精品成人欧美| 国产成人久久精品二区三区| 一本一道久久精品综合| 精品久久久久久无码中文字幕 | 国产精品久久久久久久久久影院 | jizzjizz国产精品久久| 久久精品人成免费| 久久亚洲国产午夜精品理论片| 国产精品一久久香蕉产线看| 久久综合久久综合九色| 久久WWW免费人成—看片| 亚洲人成无码www久久久| 亚洲午夜无码久久久久| 色综合久久中文综合网| 色综合久久中文字幕综合网| 99精品久久久久久久婷婷 | 亚洲成色WWW久久网站| 国产精品久久国产精麻豆99网站 | 久久国产香蕉视频| 久久精品国产亚洲αv忘忧草| 久久久久久午夜成人影院| 国产成人无码精品久久久久免费| 久久高潮一级毛片免费| 无码人妻精品一区二区三区久久久 | 成人午夜精品无码区久久| 国产精品99久久免费观看| 久久免费视频一区| 国产精品美女久久久久| 色综合久久88色综合天天 | 成人久久久观看免费毛片| 久久免费视频1| 精品国产青草久久久久福利|