Created
February 8, 2017 09:25
-
-
Save Chen-tao/edbfb476c54e199959e7c6ad42e39671 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Definition for a binary tree node. | |
* public class TreeNode { | |
* int val; | |
* TreeNode left; | |
* TreeNode right; | |
* TreeNode(int x) { val = x; } | |
* } | |
*/ | |
public class Solution { | |
public int maxDepth(TreeNode root) { | |
if(root == null) return 0; | |
int max = Math.max(maxDepth(root.left), maxDepth(root.right)); | |
return max+1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment