VERY SIMPLE Python solutions (iterative and recursive), both beat 90%
\nclass Solution(object):\n    def isBalanced(self, root):\n            \n        def check(root):\n            if root is None:\n                return 0\n    
```  \nclass Solution(object):\n    def isBalanced(self, root):\n            \n        def check(root):\n            if root is None:\n                return 0\n            left  = check(root.left)\n            right = check(root.right)\n            if left == -1 or right == -1 or abs(left - right) > 1:\n                return -1\n            return 1 + max(left, right)\n            \n        return check(root) != -1\n\n# 226 / 226 test cases passed.\n# Status: Accepted\n# Runtime: 80 ms\n```\n\n\nIterative, based on postorder traversal:\n\n```\nclass Solution(object):\n    def isBalanced(self, root):\n        stack, node, last, depths = [], root, None, {}\n        while stack or node:\n            if node:\n                stack.append(node)\n                node = node.left\n            else:\n                node = stack[-1]\n                if not node.right or last == node.right:\n                    node = stack.pop()\n                    left, right  = depths.get(node.left, 0), depths.get(node.right, 0)\n                    if abs(left - right) > 1: return False\n                    depths[node] = 1 + max(left, right)\n                    last = node\n                    node = None\n                else:\n                    node = node.right\n        return True\n\n\n# 226 / 226 test cases passed.\n# Status: Accepted\n# Runtime: 84 ms\n\n```
['Python']