[Second]Maximum Depth of Binary Tree
递归
int maxDepth(TreeNode *root) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(!root)
return 0;
int ld = maxDepth(root->left);
int rd = maxDepth(root->right);
return max(ld+1,rd+1);
}
浙公网安备 33010602011771号