Python Solution sharing
It's easy to use C++ or jave to solve this problem, but for python, the recursive limit is easy to come up.\n\nHere is a easy python solution.\nThe key is the g
It's easy to use C++ or jave to solve this problem, but for python, the recursive limit is easy to come up.\n\nHere is a easy python solution.\nThe key is the getNodeDepth uses a stack to fake recursive.\n\n\n    class Solution:\n    # @param root, a tree node\n    # @return a boolean\n    def isBalanced(self, root):\n        \n        def getNodeDepth(node):\n            if(node==None):return 0;\n\n            stack=[(node,1)];\n            dep=1;\n\n            while(len(stack)):\n                first,dep=stack.pop(0);\n                if(first.left!=None):\n                    stack.append((first.left,dep+1));\n                if(first.right!=None):\n                    stack.append((first.right,dep+1));\n            return dep;\n        \n        if(root==None):return True;\n        l=getNodeDepth(root.left);\n        r=getNodeDepth(root.right);\n        \n        return (abs(l-r)<2) and self.isBalanced(root.left) and self.isBalanced(root.right);
['Iterator', 'Python']