class Solution {
public:
/*
*
* @param root TreeNode类
* @return int整型
*/
//递归:要求二叉树的最大深度,可直接通过计算根节点层+其左右节点的最大深度中的最大值获得
int maxDepth(TreeNode
root) {
// write code here
int ans=0;
if(!root) return 0;
else
{
//ans+=1;
ans+=max(maxDepth(root->left),maxDepth(root->right))+1;
}

    return ans;
}

};