Python and don't know complexity though

  • 0
    class Solution(object):
        def isBalanced(self, root):
            :type root: TreeNode
            :rtype: bool
            self.dif = []
            def depth(node):
                if not node:
                    return 0
                left, right = depth(node.left), depth(node.right)
                return 1 + max(left, right)
            for dif in self.dif:
                if dif > 1:
                    return False
            return True

Log in to reply

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