class Solution {
public:
int TreeDepth(TreeNode* pRoot)
{
if(!pRoot)
return 0;
return max(TreeDepth(pRoot->left),TreeDepth(pRoot->right))+1;
}
};
二叉树的深度
最新推荐文章于 2024-02-22 12:51:35 发布
class Solution {
public:
int TreeDepth(TreeNode* pRoot)
{
if(!pRoot)
return 0;
return max(TreeDepth(pRoot->left),TreeDepth(pRoot->right))+1;
}
};