Learn
Practice
Newsletter
Resources
Animations
New
F
Toggle theme
0
F
0
Toggle menu
← Back to All Animations
Next Greater Element I
Bookmark
Input
Example 1
Example 2
Example 3
Custom
nums1
=
[4, 1, 2]
,
nums2
=
[1, 3, 4, 2]
nums2
1
3
4
2
0
1
2
3
stack
(empty)
map
(empty)
nums1
4
1
2
result
-1
-1
-1
monotonic stack: pop a value the moment a bigger one arrives
algo
master
.
io
Step:
Start of algorithm
0 / 25
Input
Example 1
Example 2
Example 3
Custom
nums1
=
[4, 1, 2]
,
nums2
=
[1, 3, 4, 2]
0 / 25
nums2
1
3
4
2
0
1
2
3
stack
(empty)
map
(empty)
nums1
4
1
2
result
-1
-1
-1
monotonic stack: pop a value the moment a bigger one arrives
algo
master
.
io
Step:
Start of algorithm