Skip to content

Commit ee07628

Browse files
committed
Added README.md file for Populating Next Right Pointers in Each Node II
1 parent e243c88 commit ee07628

File tree

1 file changed

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

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<h2><a href="https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii">Populating Next Right Pointers in Each Node II</a></h2> <img src='https://img.shields.io/badge/Difficulty-Medium-orange' alt='Difficulty: Medium' /><hr><p>Given a binary tree</p>
2+
3+
<pre>
4+
struct Node {
5+
int val;
6+
Node *left;
7+
Node *right;
8+
Node *next;
9+
}
10+
</pre>
11+
12+
<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>
13+
14+
<p>Initially, all next pointers are set to <code>NULL</code>.</p>
15+
16+
<p>&nbsp;</p>
17+
<p><strong class="example">Example 1:</strong></p>
18+
<img alt="" src="https://assets.leetcode.com/uploads/2019/02/15/117_sample.png" style="width: 500px; height: 171px;" />
19+
<pre>
20+
<strong>Input:</strong> root = [1,2,3,4,5,null,7]
21+
<strong>Output:</strong> [1,#,2,3,#,4,5,7,#]
22+
<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 &#39;#&#39; signifying the end of each level.
23+
</pre>
24+
25+
<p><strong class="example">Example 2:</strong></p>
26+
27+
<pre>
28+
<strong>Input:</strong> root = []
29+
<strong>Output:</strong> []
30+
</pre>
31+
32+
<p>&nbsp;</p>
33+
<p><strong>Constraints:</strong></p>
34+
35+
<ul>
36+
<li>The number of nodes in the tree is in the range <code>[0, 6000]</code>.</li>
37+
<li><code>-100 &lt;= Node.val &lt;= 100</code></li>
38+
</ul>
39+
40+
<p>&nbsp;</p>
41+
<p><strong>Follow-up:</strong></p>
42+
43+
<ul>
44+
<li>You may only use constant extra space.</li>
45+
<li>The recursive approach is fine. You may assume implicit stack space does not count as extra space for this problem.</li>
46+
</ul>

0 commit comments

Comments
 (0)