Maximum Depth of Binary Tree
求二叉树的最大深度
/** * Definition for binary tree * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ int max(int a,int b){ return a>b?a:b; } int maxDepth(struct TreeNode *root) { if(!root) return 0; if(!root->left && !root->right) return 1; return max(maxDepth(root->left),maxDepth(root->right))+1; }