二叉树高度
class Solution {
public:
int TreeDepth(TreeNode* pRoot) {
if(!pRoot) return 0;
int iLeftNodes=0;
int iRightNodes=0;
if(pRoot->left)
{
iLeftNodes=TreeDepth(pRoot->left);
}
if(pRoot->right)
{
iRightNodes=TreeDepth(pRoot->right);
}
return iLeftNodes>iRightNodes?1+iLeftNodes:1+iRightNodes;
}
};