Maximum Depth of Binary Tree LeetCode solution in Python
1# Runtime: 47 ms (Top 88.16%) | Memory: 16.3 MB (Top 23.73%)2class Solution(object):3def maxDepth(self, root):4"""5:type root: TreeNode6:rtype: int7"""8result = 09depths = []10self.handler(root, result, depths)11return max(depths)1213def handler(self, root, result, depths):14if root:15result += 116self.handler(root.left, result, depths)17self.handler(root.right, result, depths)18else:19depths.append(result)