leetcode Populating Next Right Pointers in Each Node
时间:2014-05-22 03:03:39
收藏:0
阅读:183
/**
根据完美二叉树或者非完美二叉树都可以,利用左右子树的根节点的next节点信息来连接next
*/
public void connect(TreeLinkNode root){ if(root==null) return; //利用父节点的next链接节点 if(root.left!=null){ root.left.next=root.right; } if(root.right!=null&&root.next!=null){ root.right.next=root.next.left; } connect(root.left); connect(root.right); }
leetcode Populating Next Right Pointers in Each Node,布布扣,bubuko.com
评论(0)