Solution: Populating Next Right Pointers in Each Node II
C# solution for the Populating Next Right Pointers in Each Node II problem using the Tree Breadth-First Search pattern.
We'll cover the following...
We'll cover the following...
Statement
Given the root of a binary tree root, each node contains pointers left, right, and an additional pointer next. Populate every node’s next pointer so that it points to the node immediately to its right on the same level. If there is no node to the right on that level, set next to null.
Return the root root after updating all next pointers.
Note: You must use only constant extra space. A recursive solution is allowed, and the implicit recursion stack does not count as extra space.
Constraints:
The number of nodes in the tree is in the range
...