stack that contains elements in increasing or decreasing order

pops all elements until new element is greater / less than or equal to top

Psuedo Code

num = [1,5,3,6,4]
stack = []
for num in nums:
  while stk and stk[-1] > num:`
    stk.pop()`
  stk.append(num)