- 总是记住树遍历的套路
/* 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); int r = TreeDepth(pRoot->right); return max(l,r) +1 ; } };