Created
February 18, 2014 02:49
-
-
Save blessworld/9063792 to your computer and use it in GitHub Desktop.
LeetCode:Populating Next Right Pointers in Each Node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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