@@ -0,0 +1,1755 @@
+%22%22%22Leetcode 427. Construct Quad Tree%0AMedium%0A%0AURL: https://leetcode.com/problems/construct-quad-tree/%0A%0AWe want to use quad trees to store an N x N boolean grid. Each cell in the grid can%0Aonly be true or false. The root node represents the whole grid. For each node,%0Ait will be subdivided into four children nodes until the values in the region it%0Arepresents are all the same.%0A%0AEach node has another two boolean attributes : isLeaf and val. isLeaf is true if%0Aand only if the node is a leaf node. The val attribute for a leaf node contains%0Athe value of the region it represents.%0A%0AYour task is to use a quad tree to represent a given grid. The following example%0Amay help you understand the problem better:%0A%5BImage skipped%5D%0A%0AGiven the 8 x 8 grid below, we want to construct the corresponding quad tree:%0A%5BImage skipped%5D%0A%0AIt can be divided according to the definition above:%0A%5BImage skipped%5D%0A%0AThe corresponding quad tree should be as following, where each node is represented%0Aas a (isLeaf, val) pair.%0A%0AFor the non-leaf nodes, val can be arbitrary, so it is represented as '*'.%0A%0ANote:%0A- N is less than 1000 and guaranteened to be a power of 2.%0A- If you want to know more about the quad tree, you can refer to its wiki.%0A%22%22%22%0A%0A# Definition for a QuadTree node.%0Aclass Node(object):%0A    def __init__(self, val, isLeaf, topLeft, topRight, bottomLeft, bottomRight):%0A        self.val = val%0A        self.isLeaf = isLeaf%0A        self.topLeft = topLeft%0A        self.topRight = topRight%0A        self.bottomLeft = bottomLeft%0A        self.bottomRight = bottomRight%0A%0A%0Aclass Solution(object):%0A    def construct(self, grid):%0A        %22%22%22%0A        :type grid: List%5BList%5Bint%5D%5D%0A        :rtype: Node%0A        %22%22%22%0A        pass%0A%0A%0Adef main():%0A    pass%0A%0A%0Aif __name__ == '__main__':%0A    main()%0A

Add lc0427_construct_quad_tree.py