/*
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 == NULL)
return 0;
//递归调用
//深度就是返回值+1
return 1+max(TreeDepth(pRoot->left),TreeDepth(pRoot->right));
}
};
标签:right,TreeNode,struct,int,pRoot,二叉树,深度,JZ55,NULL
From: https://www.cnblogs.com/H43724334/p/18136956