131. Populating Next Right Pointers in Each Node II

Given a binary tree, fill in the Next pointers so that each node points to its right-hand neighbor on the same level (or NULL). The tree may be imperfect.
Example 1
Input: root = [1,2,3]
Output: [1,#,2,3,#]
Explanation: Three nodes across two levels.
Example 2
Input: root = [1,2,3,4,5,null,7]
Output: [1,#,2,3,#,4,5,7,#]
Explanation: Nodes at each level are linked, including in an incomplete tree.
binary treemediumrecursiontree
JavaScript
Loading...
Line 1, Char 1