forked from YaxeZhang/Just-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathall-possible-full-binary-trees.md
More file actions
26 lines (17 loc) · 1.03 KB
/
all-possible-full-binary-trees.md
File metadata and controls
26 lines (17 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<p>A <em>full binary tree</em> is a binary tree where each node has exactly 0 or 2 children.</p>
<p>Return a list of all possible full binary trees with <code>N</code> nodes. Each element of the answer is the root node of one possible tree.</p>
<p>Each <code>node</code> of each tree in the answer <strong>must</strong> have <code>node.val = 0</code>.</p>
<p>You may return the final list of trees in any order.</p>
<p> </p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input: </strong><span id="example-input-1-1">7</span>
<strong>Output: </strong><span id="example-output-1">[[0,0,0,null,null,0,0,null,null,0,0],[0,0,0,null,null,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,null,null,null,null,0,0],[0,0,0,0,0,null,null,0,0]]</span>
<strong>Explanation:</strong>
<img alt="" src="https://s3-lc-upload.s3.amazonaws.com/uploads/2018/08/22/fivetrees.png" style="width: 700px; height: 400px;" />
</pre>
<p> </p>
<p><strong>Note:</strong></p>
<ul>
<li><code>1 <= N <= 20</code></li>
</ul>