Stack coding problems

Stack problems cover balanced brackets, expression evaluation and the monotonic stack trick behind next greater element and largest rectangle questions.

29 problems: 13 easy, 13 medium, 3 hard. Free to read; a free account solves them and earns XP and Aura.

  1. Find Previous Smaller ElementPractice · +10 XPeasy
  2. Last Element in RangePractice · +10 XPeasy
  3. Max Element in PrefixPractice · +10 XPeasy
  4. Print Elements Larger Than PreviousPractice · +10 XPeasy
  5. Print Previous Smaller ElementPractice · +10 XPeasy
  6. Print Stack SizePractice · +10 XPeasy
  7. Queue ReverserPractice · +10 XPeasy
  8. Reverse a StringPractice · +10 XPeasy
  9. Reverse First K ElementsPractice · +10 XPeasy
  10. Simple Bracket CheckerPractice · +10 XPeasy
  11. Stack of IntegersPractice · +10 XPeasy
  12. Stack Push CounterPractice · +10 XPeasy
  13. Valid BracketsPractice · +10 XPeasy
  14. Balanced Parentheses SubsequencePractice · +20 XPmedium
  15. Distinct Elements in Sliding WindowPractice · +20 XPmedium
  16. Find Closest Smaller ElementPractice · +20 XPmedium
  17. Indices of Next Smaller ElementPractice · +20 XPmedium
  18. Largest Rectangle Under HistogramPractice · +20 XPmedium
  19. Longest Prefix with Equal CountsPractice · +20 XPmedium
  20. Maximum Sum of Non-Overlapping Positive SubarraysPractice · +20 XPmedium
  21. Next Greater Element in a Cyclic ArrayPractice · +20 XPmedium
  22. Next Greater Element on RightPractice · +20 XPmedium
  23. Stack Maximum DifferencePractice · +20 XPmedium
  24. Subarray Sum RangePractice · +20 XPmedium
  25. Sum of Minimums of All SubarraysPractice · +20 XPmedium
  26. Sum of Next Greater Element PairsPractice · +20 XPmedium
  27. Largest Rectangle in a HistogramPractice · +30 XPhard
  28. Longest Increasing Subsequence with Stack ConstraintPractice · +30 XPhard
  29. Subarray Minimums with SumPractice · +30 XPhard