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