Last Minute Notes
Github
Docs
Learn
Search
⌘
K
@sayanstwt
Lessons
Learn
/
Data Structures & Algorithms
/
Arrays & Strings
Monotonic Stack
7 min
Intermediate
8 steps
Find the next greater element for every item in O(n).
Day
2: 75
Checks
1
Worst case
O(n²)
TEMPS
scanning
0
1
2
3
4
5
6
7
73
74
75
71
69
72
76
73
day
j
current
done
skipped
In this lesson
Step 1 of 8
1
The problem
2
The stack
3
Pop
4
Full run
5
Why O(n)
6
Leftovers
7
Flip it
8
Recap