Simple & Short Python Beats 99%

  • 0
    class Solution(object):
        def maxDepth(self, root):
            :type root: TreeNode
            :rtype: int
            def treeDepth(root, depth):
                if not root:
                    return depth - 1
                return max(treeDepth(root.left, depth+1), treeDepth(root.right, depth+1))
            return treeDepth(root, 1)

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.