求二叉树的最大高度
1. 空树最大深度是0. 2. max(左子树的最大深度, 右子树最大深度) + 1
// 104. Maximum Depth of Binary Tree
// 1. 空树最大深度是0. 2. max(左子树的最大深度, 右子树最大深度) + 1
int solution::maxDepth(TreeNode* root)
{
if (root == NULL) return 0;
int leftDepth = maxDepth(root->left);
int rightDepth = maxDepth(root->right);
return leftDepth > rightDepth ? leftDepth + 1 : rightDepth + 1;
}