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.
- Find Previous Smaller ElementPractice · +10 XP · stack, monotonic stackeasy
- Last Element in RangePractice · +10 XP · stack, arrayseasy
- Max Element in PrefixPractice · +10 XP · stack, prefix sums, arrayseasy
- Print Elements Larger Than PreviousPractice · +10 XP · stack, basic programming, iterationeasy
- Print Previous Smaller ElementPractice · +10 XP · stackeasy
- Print Stack SizePractice · +10 XP · stackeasy
- Queue ReverserPractice · +10 XP · queue, stack, simulationeasy
- Reverse a StringPractice · +10 XP · stack, stringeasy
- Reverse First K ElementsPractice · +10 XP · queue, stack, simulationeasy
- Simple Bracket CheckerPractice · +10 XP · stack, bracket matching, beginnereasy
- Stack of IntegersPractice · +10 XP · stackeasy
- Stack Push CounterPractice · +10 XP · stack, simulation, arrayseasy
- Valid BracketsPractice · +10 XP · stack, stringseasy
- Balanced Parentheses SubsequencePractice · +20 XP · queue, stack, simulationmedium
- Distinct Elements in Sliding WindowPractice · +20 XP · stack, hash map, sliding windowmedium
- Find Closest Smaller ElementPractice · +20 XP · stack, monotonic stack, arraymedium
- Indices of Next Smaller ElementPractice · +20 XP · stack, monotonic stack, arraymedium
- Largest Rectangle Under HistogramPractice · +20 XP · stack, monotonic stack, area calculationmedium
- Longest Prefix with Equal CountsPractice · +20 XP · stack, hash map, prefix summedium
- Maximum Sum of Non-Overlapping Positive SubarraysPractice · +20 XP · stack, dynamic programming, greedymedium
- Next Greater Element in a Cyclic ArrayPractice · +20 XP · queue, stack, monotonic stackmedium
- Next Greater Element on RightPractice · +20 XP · stack, monotonic stack, arraysmedium
- Stack Maximum DifferencePractice · +20 XP · stack, monotonic stack, arraymedium
- Subarray Sum RangePractice · +20 XP · stack, monotonic stack, prefix summedium
- Sum of Minimums of All SubarraysPractice · +20 XP · stack, monotonic stack, prefix summedium
- Sum of Next Greater Element PairsPractice · +20 XP · stack, array, monotonic stackmedium
- Largest Rectangle in a HistogramPractice · +30 XP · monotonic stack, arrayshard
- Longest Increasing Subsequence with Stack ConstraintPractice · +30 XP · stack, dynamic programming, greedyhard
- Subarray Minimums with SumPractice · +30 XP · arrays, monotonic stack, prefix sumshard
Solve these free. Get paid in XP and Aura.
One tap with Google, no card. Every first accepted solve pays XP for the leaderboards and Aura for real goodies.
Other topics
Hash Map and Hashing101Arrays88Prefix Sums64SQL and Databases64Beginner Coding Problems60Graphs, BFS and DFS45Greedy41Sliding Window39Dynamic Programming37Sorting36Math and Number Theory36Strings35Two Pointers35Binary Search25Simulation25Recursion22Linked List20Trees20Heap and Priority Queue18Matrix and Grid18Bit Manipulation18Queue and Deque16