104. Maximum Depth of Binary Tree#

1public int maxDepth(TreeNode root) {
2  if (root == null) return 0;
3  return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1;
4}