Design a Max Stack that supports push, pop, top, peekMax (return max without removing it), and popMax (remove and return the max element), all with O(1) or better amortized time.
Enable JavaScript for the full StreamPrep guide.