Python Inorder Traversal Solution


  • 0
    P
    def isValidBST(self, root):
        """
        :type root: TreeNode
        :rtype: bool
        """
        result = []
        
        def inorder(root, result) :
            if root :
                inorder(root.left, result)
                result.append(root.val)
                inorder(root.right, result)
        inorder(root, result)
        
        return sorted(list(set(result))) == result

Log in to reply
 

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