• <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
            基于一個值為0或1的方陣構(gòu)建Quad Tree,DFS


             1 #427
             2 #Runtime: 100 ms (Beats 98.35%)
             3 #Memory: 14.7 MB (Beats 86.50%)
             4 
             5 class Node:
             6     def __init__(self, val, isLeaf, topLeft = None, topRight = None, bottomLeft = None, bottomRight = None):
             7         self.val = val
             8         self.isLeaf = isLeaf
             9         self.topLeft = topLeft
            10         self.topRight = topRight
            11         self.bottomLeft = bottomLeft
            12         self.bottomRight = bottomRight
            13 
            14 
            15 class Solution:
            16     def isLeaf(self, grid, x, y, w):
            17         for i in range(x, x + w):
            18             for j in range(y, y + w):
            19                 if grid[x][y] != grid[i][j]:
            20                     return False
            21         return True
            22 
            23     def BuildTree(self, grid, x, y, w):
            24         if self.isLeaf(grid, x, y, w):
            25             return Node(grid[x][y] == 1, True)
            26         r = Node(True, False)
            27         r.topLeft = self.BuildTree(grid, x, y, w // 2)
            28         r.topRight = self.BuildTree(grid, x, y + w // 2, w // 2)
            29         r.bottomLeft = self.BuildTree(grid, x + w // 2, y, w // 2)
            30         r.bottomRight = self.BuildTree(grid, x + w // 2, y + w // 2, w // 2)
            31         return r
            32 
            33     def construct(self, grid: List[List[int]]) -> Node:
            34         return self.BuildTree(grid, 0, 0, len(grid))
            亚洲国产精品无码久久久蜜芽| 国产A级毛片久久久精品毛片| 久久精品国产亚洲AV电影| 亚洲AV无码久久精品色欲| 午夜欧美精品久久久久久久| 一本久道久久综合狠狠爱| 国产午夜免费高清久久影院| 秋霞久久国产精品电影院| 久久婷婷午色综合夜啪| 97热久久免费频精品99| 日韩电影久久久被窝网| 日韩av无码久久精品免费| 精品久久久久久国产免费了| 狠狠综合久久综合88亚洲| 99久久精品日本一区二区免费| 精品久久久久国产免费| 男女久久久国产一区二区三区| 亚洲成人精品久久| 久久久久av无码免费网| 99久久精品免费看国产一区二区三区 | 欧美国产成人久久精品| 精品少妇人妻av无码久久| 亚洲国产视频久久| 久久精品一区二区影院 | 国产精品久久久久免费a∨| 国产精品久久免费| 久久久久久无码Av成人影院| 久久亚洲精品国产亚洲老地址| 丁香五月综合久久激情| 久久Av无码精品人妻系列 | 国产精品久久久久久吹潮| 久久99这里只有精品国产| 久久久久久久综合日本| 91久久精品电影| 国产精品久久自在自线观看| 欧美丰满熟妇BBB久久久| 亚洲精品乱码久久久久久中文字幕 | 久久久久无码精品国产不卡| 狠狠色丁香久久婷婷综合| 亚洲欧美久久久久9999| 久久午夜免费视频|