int maxDepth(struct TreeNode* root){
if (root == NULL) {
return 0;
}
int lenLeft = maxDepth(root->left) + 1;
int lenRight = maxDepth(root->right) + 1;
return lenLeft > lenRight ? lenLeft : lenRight;
}
原文:https://www.cnblogs.com/ganxiang/p/13552070.html