My Python Solution


  • 0
    L
    class Solution(object):
        def maxDepth(self, root):
            """
            :type root: TreeNode
            :rtype: int
            """
            if isinstance(root, TreeNode):
                left = self.maxDepth(root.left)
                right = self.maxDepth(root.right)
                return max(left, right) + 1
            else:
                return 0
    

Log in to reply
 

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