public class Solution {
public void connect(TreeLinkNode root) {
while (root != null) {
TreeLinkNode tempChild = new TreeLinkNode(0);
TreeLinkNode currentChild = tempChild;
while (root != null) {
if (root.left != null) {
currentChild.next = root.left;
currentChild = currentChild.next;
}
if (root.right != null) {
currentChild.next = root.right;
currentChild = currentChild.next;
}
root = root.next;
}
root = tempChild.next;
}
}
}
117. Populating Next Right Pointers in Each Node II
原文:https://www.cnblogs.com/MarkLeeBYR/p/10536166.html