Maximum Depth of Binary Tree
class Solution:
def maxDepth(self, root: Optional[TreeNode]) -> int:
def get_depth(node):
if not node:
return 0
cmax = 0
cmax = max(cmax, 1 + get_depth(node.left))
cmax = max(cmax, 1 + get_depth(node.right))
return cmax
return get_depth(root)