[leetcode] Maxinum Depth of Binary Tree 二叉树最大深度
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
int maxDepth(TreeNode* root) {
if(root==NULL)return 0;
int d1=maxDepth(root->left);
int d2=maxDepth(root->right);
return max(d1,d2)+1;
}
};