Leetcode 116, Populating Next Right Pointers in Each Node
2016-12-24 00:01
387 查看
public void connect(TreeLinkNode root) {
if(root == null){
return;
}
if(root.left != null){
root.left.next = root.right;
}
if(root.right != null){
if(root.next != null){
root.right.next = root.next.left;
}
}
connect(root.left);
connect(root.right);
}
if(root == null){
return;
}
if(root.left != null){
root.left.next = root.right;
}
if(root.right != null){
if(root.next != null){
root.right.next = root.next.left;
}
}
connect(root.left);
connect(root.right);
}
相关文章推荐
- leetcode_question_116 Populating Next Right Pointers in Each Node
- LeetCode(116) Populating Next Right Pointers in Each Node
- leetcode-116-Populating Next Right Pointers in Each Node
- leetcode 116 —— Populating Next Right Pointers in Each Node
- leetcode116 Populating Next Right Pointers in Each Node
- LeetCode 116 Populating Next Right Pointers in Each Node
- LeetCode 116 Populating Next Right Pointers in Each Node
- LeetCode 116. Populating Next Right Pointers in Each Node
- Populating Next Right Pointers in Each Node - LeetCode 116
- [LeetCode 116 117] - 填充每一个节点的指向右边邻居的指针I & II (Populating Next Right Pointers in Each Node I & II)
- LeetCode 116. Populating Next Right Pointers in Each Node
- leetcode[116]Populating Next Right Pointers in Each Node
- leetcode || 116、Populating Next Right Pointers in Each Node
- LeetCode(116) Populating Next Right Pointers in Each Node
- [leetcode 116] Populating Next Right Pointers in Each Node
- Leetcode 笔记 116 - Populating Next Right Pointers in Each Node
- Leetcode#116 Populating Next Right Pointers in Each Node
- Leetcode_116_Populating Next Right Pointers in Each Node
- [Leetcode 116, Medium] Populating Next Right Pointers in Each Node
- [Leetcode] 116. Populating Next Right Pointers in Each Node