Given the root of a next, connect each node to the next node from left to right. For nodes that have a right sibling, next points to that sibling. For the rightmost node of each level, next points to the first node of the next level. The rightmost node of the final level points to NULL.
Constraints:
The number of nodes in the tree is in the range
Node.data
Given the root of a next, connect each node to the next node from left to right. For nodes that have a right sibling, next points to that sibling. For the rightmost node of each level, next points to the first node of the next level. The rightmost node of the final level points to NULL.
Constraints:
The number of nodes in the tree is in the range
Node.data