二叉树的所有基本上就是,递归,递归,递归√
class Solution {
public:
int TreeDepth(TreeNode* pRoot)
{
if(pRoot)
{
int le=0,ri=0,maxtree;
le = TreeDepth(pRoot->left);
ri = TreeDepth(pRoot->right);
maxtree = le>ri?le:ri;
return maxtree+1;
}
else
return 0;
}
};