My accepted solution in Python


  • 1
    C
        def maxDepth(self, root):
            if root == None:
                return 0
            l,r = 1,1
            if root.left != None:
                l = l+self.maxDepth(root.left)
            if root.right != None:
                r = r+self.maxDepth(root.right)
            if l>r:
                return l
            else:
                return r

Log in to reply
 

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