Skip to content

Instantly share code, notes, and snippets.

@blessworld
Created February 18, 2014 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blessworld/9063792 to your computer and use it in GitHub Desktop.
Save blessworld/9063792 to your computer and use it in GitHub Desktop.
LeetCode:Populating Next Right Pointers in Each Node
import com.sun.org.apache.regexp.internal.recompile;
/**
* Created by thedarkknight on 14-2-15.
*/
public class Solution {
public void connect(TreeLinkNode root) {
if (root == null)
return ;
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);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment