Easy python inorder traversal solution

  • 0
    class Solution(object):
        def __init__(self):
            self.prev = None
        def isValidBST(self, root):
            if not root:
                return True
            LTree = self.isValidBST(root.left)
            if self.prev is not None and root.val <= self.prev:
                return False
            self.prev = root.val
            RTree = self.isValidBST(root.right)
            return LTree and RTree

Log in to reply

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