JasonChang

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

recursion programming

画图看特点

 1 public class Solution {
 2     public void connect(TreeLinkNode root) {
 3         // IMPORTANT: Please reset any member data you declared, as
 4         // the same Solution instance will be reused for each test case.
 5         if(root == null)
 6             return;
 7         if(root.left != null)
 8             root.left.next = root.right;
 9         if(root.right != null)
10             root.right.next = root.next == null?null:root.next.left;
11         connect(root.left);
12         connect(root.right);
13     }
14 }

 

posted on 2013-11-11 14:19  JasonChang  阅读(186)  评论(0)    收藏  举报