class Solution
{
public:
int maxDepth(TreeNode* root)
{
if (root == NULL)
return 0;
if (root->left && root->right)
return std::max(maxDepth(root->left), maxDepth(root->right)) + 1;
else if (root->left)
return maxDepth(root->left) + 1;
else if (root->right)
return maxDepth(root->right) + 1;
else
return 1;
}
};