//树的最大深度
/*
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 次
全部评论
相关推荐
10-19 12:41
成都工业学院 嵌入式软件开发
嵌入式的小白:简历关键的就是项目经历,你这密密麻麻的,我一点开就不想看了,每一条都不换行,而且每一个里面写那么多,需要精简一下,这样别人看一眼就能知道你做了啥,用了啥技术 点赞 评论 收藏
分享
点赞 评论 收藏
分享
查看5道真题和解析
