CodeWizard
learn to code more, code to learn more.
Monday, March 4, 2013
[LeetCode] Maximum Depth of Binary Tree
Thought:
What's the problem....
Code:
public class Solution {
public int maxDepth(TreeNode root) {
if (root == null) return 0;
else return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1;
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment