题目:
二叉树深度
代码:
class Solution {
public:
int TreeDepth(TreeNode* pRoot)
{
if(NULL == pRoot)
{
return 0;
}
int left = NULL != pRoot->left ? TreeDepth(pRoot->left) : 0;
int right = NULL != pRoot->right ? TreeDepth(pRoot->right) : 0;
return max(left, right) + 1;
}
};