标签:title class 题目 div font 二叉树 16px 输入 str
【思路1】递归
1 /* 2 struct TreeNode { 3 int val; 4 struct TreeNode *left; 5 struct TreeNode *right; 6 TreeNode(int x) : 7 val(x), left(NULL), right(NULL) { 8 } 9 };*/ 10 class Solution { 11 public: 12 int TreeDepth(TreeNode* pRoot) 13 { 14 if(pRoot == NULL) 15 return 0; 16 int h1 = TreeDepth(pRoot->left); 17 int h2 = TreeDepth(pRoot->right); 18 return max(h1,h2) + 1; 19 } 20 };
标签:title class 题目 div font 二叉树 16px 输入 str
原文地址:http://www.cnblogs.com/lca1826/p/6515963.html