class Solution:
    def verifyPreorder(self, preorder: List[int]) -> bool:
        """
        Time O(N) space O(N)
        stack to track left substree and parent node 
        note the stack is mono  decreasing stack 
    
    
    lo            2
        [5,2,1] [5,3]
        """
        st = []
        lo = float('-inf')
        for p in preorder:
            print(p,lo,st)
            if p < lo:
                return False 
            
            while st and st[-1] < p :
                lo = st.pop()
            st.append(p)
        return True