二叉树的最大深度
代码部分:
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
int maxDepth(struct TreeNode* root) {
int maxDepth(struct TreeNode* root) {
if(!root ) return 0;
return max(maxDepth(root->left),maxDepth(root->right))+1;
}
}