Monotonic Stack
13 problems
A monotonic stack maintains elements in strictly increasing or decreasing order. When a new element violates this order, elements are popped and processed. Use for "next greater / smaller element", histogram area, and stock span problems. Each element is pushed and popped at most once — O(n) overall.
- 239.Sliding Window MaximumHard
- 316.Remove Duplicate LettersMedium
- 321.Create Maximum NumberUnknown
- 769.Max Chunks To Make SortedMedium
- 862.Shortest Subarray with Sum at Least KHard
- 962.Maximum Width RampMedium
- 1081.Smallest Subsequence of Distinct CharactersMedium
- 1475.Final Prices With a Special Discount in a ShopEasy
- 1526.Minimum Number of Increments on Subarrays to Form a Target ArrayUnknown
- 1574.Shortest Subarray to be Removed to Make Array SortedUnknown
- 2444.Count Subarrays With Fixed BoundsHard
- 2818.Apply Operations to Maximize ScoreUnknown
- 2940.Find Building Where Alice and Bob Can MeetUnknown