last-in first-out structure (i.e. one-sided)

nearest smaller element

finding closest element to left of some where

  • add pairs of and to stack
  • remove from top of stack until top is less than current array
  • add top stack to , add current array and to stack