二叉树的深度

class Solution {  
public:  
    int TreeDepth(TreeNode* pRoot)  
    {  
        if( !pRoot )  
           return 0;  
           
           int left  = TreeDepth(pRoot->left);  
           int right = TreeDepth(pRoot->right);  
           return left > right ? ( left + 1 ) : ( right + 1 );  
    }  
};  

 

posted on 2017-03-01 01:21  123_123  阅读(82)  评论(0编辑  收藏  举报