leetcode-剑指55-I-OK
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
// 带着深度递归
int maxDepth(struct TreeNode* root){
if(root == NULL)
return 0;
int max = 1;
void taowa(struct TreeNode* one, int depth){ //自身的depth
if(depth> max)
max = depth;
if(one->left)
taowa(one->left, depth+1);
if(one->right)
taowa(one->right, depth+1);
}
taowa(root,1);
return max;
}