My in-order solution

  • 0
    class Solution(object):
        def isValidBST(self, root):
            stack, inorder = [], []
            while root:
                root = root.left
            while stack:
                top = stack.pop()
                tmp = top.right
                while tmp:
                    tmp = tmp.left
            for i in xrange(1, len(inorder)):
                if inorder[i] <= inorder[i - 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.