解题思路:
(1)递归求左右子树的最大的高度
(2)注意这个长度指的是间隔数还是结点数
/*
struct TreeNode {
int val;
struct TreeNode *left;
struct TreeNode *right;
TreeNode(int x) :
val(x), left(NULL), right(NULL) {
}
};*/
class Solution {
public:
int TreeDepth(TreeNode* pRoot) {
if(pRoot==NULL) return 0;
int l = TreeDepth(pRoot->left),r = TreeDepth(pRoot->right);
return max(l,r)+1;
}
};