Skip to content

Commit a94bb68

Browse files
committed
Create README - LeetHub
1 parent 4ef9e81 commit a94bb68

File tree

1 file changed

+44
-0
lines changed
  • 117-populating-next-right-pointers-in-each-node-ii

1 file changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<h2><a href="https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/">117. Populating Next Right Pointers in Each Node II</a></h2><h3>Medium</h3><hr><div><p>Given a binary tree</p>
2+
3+
<pre>struct Node {
4+
int val;
5+
Node *left;
6+
Node *right;
7+
Node *next;
8+
}
9+
</pre>
10+
11+
<p>Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to <code>NULL</code>.</p>
12+
13+
<p>Initially, all next pointers are set to <code>NULL</code>.</p>
14+
15+
<p>&nbsp;</p>
16+
<p><strong>Example 1:</strong></p>
17+
<img alt="" src="https://assets.leetcode.com/uploads/2019/02/15/117_sample.png" style="width: 500px; height: 171px;">
18+
<pre><strong>Input:</strong> root = [1,2,3,4,5,null,7]
19+
<strong>Output:</strong> [1,#,2,3,#,4,5,7,#]
20+
<strong>Explanation: </strong>Given the above binary tree (Figure A), your function should populate each next pointer to point to its next right node, just like in Figure B. The serialized output is in level order as connected by the next pointers, with '#' signifying the end of each level.
21+
</pre>
22+
23+
<p><strong>Example 2:</strong></p>
24+
25+
<pre><strong>Input:</strong> root = []
26+
<strong>Output:</strong> []
27+
</pre>
28+
29+
<p>&nbsp;</p>
30+
<p><strong>Constraints:</strong></p>
31+
32+
<ul>
33+
<li>The number of nodes in the tree is in the range <code>[0, 6000]</code>.</li>
34+
<li><code>-100 &lt;= Node.val &lt;= 100</code></li>
35+
</ul>
36+
37+
<p>&nbsp;</p>
38+
<p><strong>Follow-up:</strong></p>
39+
40+
<ul>
41+
<li>You may only use constant extra space.</li>
42+
<li>The recursive approach is fine. You may assume implicit stack space does not count as extra space for this problem.</li>
43+
</ul>
44+
</div>

0 commit comments

Comments
 (0)