class Solution {
public:
int maxDepth(TreeNode* root) {
if(!root)return 0;
int l = 0;
int r = 0;
if(root->left){
l = maxDepth(root->left);
}
if(root->right){
r = maxDepth(root->right);
}
return l>r?(l+1):(r+1);
}
};
leetcode--Maximum Depth of Binary Tree
原文:http://www.cnblogs.com/blackding/p/5026528.html