mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-06 16:01:41 +08:00
存量题库数据更新
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
<p>Given a <code>n * n</code> matrix <code>grid</code> of <code>0's</code> and <code>1's</code> only. We want to represent the <code>grid</code> with a Quad-Tree.</p>
|
||||
<p>Given a <code>n * n</code> matrix <code>grid</code> of <code>0's</code> and <code>1's</code> only. We want to represent <code>grid</code> with a Quad-Tree.</p>
|
||||
|
||||
<p>Return <em>the root of the Quad-Tree</em> representing the <code>grid</code>.</p>
|
||||
|
||||
<p>Notice that you can assign the value of a node to <strong>True</strong> or <strong>False</strong> when <code>isLeaf</code> is <strong>False</strong>, and both are <strong>accepted</strong> in the answer.</p>
|
||||
<p>Return <em>the root of the Quad-Tree representing </em><code>grid</code>.</p>
|
||||
|
||||
<p>A Quad-Tree is a tree data structure in which each internal node has exactly four children. Besides, each node has two attributes:</p>
|
||||
|
||||
<ul>
|
||||
<li><code>val</code>: True if the node represents a grid of 1's or False if the node represents a grid of 0's.</li>
|
||||
<li><code>isLeaf</code>: True if the node is leaf node on the tree or False if the node has the four children.</li>
|
||||
<li><code>val</code>: True if the node represents a grid of 1's or False if the node represents a grid of 0's. Notice that you can assign the <code>val</code> to True or False when <code>isLeaf</code> is False, and both are accepted in the answer.</li>
|
||||
<li><code>isLeaf</code>: True if the node is a leaf node on the tree or False if the node has four children.</li>
|
||||
</ul>
|
||||
|
||||
<pre>
|
||||
@@ -33,24 +31,24 @@ class Node {
|
||||
|
||||
<p><strong>Quad-Tree format:</strong></p>
|
||||
|
||||
<p>The output represents the serialized format of a Quad-Tree using level order traversal, where <code>null</code> signifies a path terminator where no node exists below.</p>
|
||||
<p>You don't need to read this section for solving the problem. This is only if you want to understand the output format here. The output represents the serialized format of a Quad-Tree using level order traversal, where <code>null</code> signifies a path terminator where no node exists below.</p>
|
||||
|
||||
<p>It is very similar to the serialization of the binary tree. The only difference is that the node is represented as a list <code>[isLeaf, val]</code>.</p>
|
||||
|
||||
<p>If the value of <code>isLeaf</code> or <code>val</code> is True we represent it as <strong>1</strong> in the list <code>[isLeaf, val]</code> and if the value of <code>isLeaf</code> or <code>val</code> is False we represent it as <strong>0</strong>.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
<img alt="" src="https://assets.leetcode.com/uploads/2020/02/11/grid1.png" style="width: 777px; height: 99px;" />
|
||||
<pre>
|
||||
<strong>Input:</strong> grid = [[0,1],[1,0]]
|
||||
<strong>Output:</strong> [[0,1],[1,0],[1,1],[1,1],[1,0]]
|
||||
<strong>Explanation:</strong> The explanation of this example is shown below:
|
||||
Notice that 0 represnts False and 1 represents True in the photo representing the Quad-Tree.
|
||||
Notice that 0 represents False and 1 represents True in the photo representing the Quad-Tree.
|
||||
<img alt="" src="https://assets.leetcode.com/uploads/2020/02/12/e1tree.png" style="width: 777px; height: 186px;" />
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<p><img alt="" src="https://assets.leetcode.com/uploads/2020/02/12/e2mat.png" style="width: 777px; height: 343px;" /></p>
|
||||
|
||||
|
Reference in New Issue
Block a user