Given a binarytree, find its maximum depth.
The maximumdepth is the number of nodes along the longest path from the root node down tothe farthest leaf node.
/**
* Definitionfor binary tree
* structTreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL),right(NULL) {}
* };
*/
class Solution {
public:
intmaxDepth(TreeNode *root) {
if(root== NULL) return 0;
int le =maxDepth(root->left)+1;
int ri =maxDepth(root->right)+1;
returnle>ri?le:ri;
}
};