Last active
August 5, 2017 01:26
-
-
Save cixuuz/6fe96c9b1c01953b30b28751e4e4cde0 to your computer and use it in GitHub Desktop.
[104 Maximum Depth of Binary Tree] #leetcode
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
public class Solution { | |
public int maxDepth(TreeNode root) { | |
if (root == null) { | |
return 0; | |
} | |
return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment