标签:style blog color io ar art div sp log
1 public class Solution { 2 public void connect(TreeLinkNode root) { 3 if (root==null) return; 4 TreeLinkNode upperLevelStartNode = root; 5 6 while(upperLevelStartNode.left!=null) { 7 TreeLinkNode travelingNode=upperLevelStartNode; 8 while (true) { 9 travelingNode.left.next=travelingNode.right; 10 if (travelingNode.next == null) break; 11 travelingNode.right.next = travelingNode.next.left; 12 travelingNode = travelingNode.next; 13 } 14 upperLevelStartNode = upperLevelStartNode.left; 15 } 16 } 17 }
[LeetCode] Populating Next Right Pointers in Each Node
标签:style blog color io ar art div sp log
原文地址:http://www.cnblogs.com/yuhaos/p/3965095.html