二叉树深度

class Solution {
public:
    int TreeDepth(TreeNode* pRoot)
    {
        if(pRoot == NULL)
            return 0;
        int depth,left,right;
        left = TreeDepth(pRoot->left);
        right = TreeDepth(pRoot->right);
        depth = left > right ? left+1 : right+1;
        return depth;
    }
};
原文地址:https://www.cnblogs.com/ymjyqsx/p/9644982.html