This site uses JavaScript for navigation, themes, and games like 2048. Please enable JavaScript in your browser settings, then reload the page.
13 problems. Click one to open the details.
0/13 solved
1.Nearest Greater to Right
For every index, find the nearest strictly greater element to its right using a monotonic stack.
2.Nearest Greater to Left
Find the nearest strictly greater element to the left of each index with a left-to-right monotonic stack.
3.Nearest Smaller to Left
Find the nearest strictly smaller element to the left of each index.
4.Nearest Smaller to Right
Find the nearest strictly smaller element to the right of each index.
5.Stock Span Problem
Compute consecutive days the price was less than or equal to today's price — NGL distance.
6.Maximum Area Histogram
Largest rectangle area in a histogram using nearest smaller left/right boundaries.
7.Max Area Rectangle in Binary Matrix
Treat each matrix row as a histogram base and reuse MAH for the largest 1s rectangle.
8.Rain Water Trapping
Compute trapped rain water using left/right max bars (or two pointers / stack).
9.Min Element in Stack (O(1) Extra Space)
Design a stack that supports push, pop, top, and getMin in O(1) time using encoded values.
10.Delete Middle of Stack
Delete the middle element of a stack using recursion without extra data structures.
11.Reverse a Stack using Recursion
Reverse a stack in place using only recursion (insert-at-bottom helper).
12.Asteroid Collision
Stack simulation of colliding asteroids.
13.LRU Cache
O(1) get/put with hashmap + doubly linked list.