# 104. Maximum Depth of Binary Tree # https://leetcode.com/problems/maximum-depth-of-binary-tree # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def maxDepth(self, root: Optional[TreeNode]) -> int: return 1 + max(map(self.maxDepth, (root.left, root.right))) if root else 0