//树的最大深度
/*
struct TreeNode {
int val;
struct TreeNode *left;
struct TreeNode *right;
TreeNode(int x) :
val(x), left(NULL), right(NULL) {
}
};*/
class Solution {
public:
int TreeDepth(TreeNode* pRoot)
{
if(!pRoot) return 0;
return max(TreeDepth(pRoot->left),TreeDepth(pRoot->right))+1;
}
};
/*
struct TreeNode {
int val;
struct TreeNode *left;
struct TreeNode *right;
TreeNode(int x) :
val(x), left(NULL), right(NULL) {
}
};*/
class Solution {
public:
int TreeDepth(TreeNode* pRoot)
{
if(!pRoot) return 0;
return max(TreeDepth(pRoot->left),TreeDepth(pRoot->right))+1;
}
};
2020-05-17
在牛客打卡25天,今天学习:刷题 3 道/代码提交 3 次
全部评论
相关推荐