FrontendX
Stock Span Problem
medium
Description
AI Assistance
Solution
Test Cases
Test Result
Submissions
Canvas
Stock Span
Problem
Find span of stock prices using monotonic stack.
Examples
Example 1
Input:
[1,2,3]
Output:
[1,2,3]
Example 2
Input:
[1,2,3]
Output:
[1,2,3]
Hints
Hint 1
Span = current index - previous greater element index.
Hint 2
Use a monotonic decreasing stack.
Hint 3
Store indices, calculate span when popping.
Stock Span Problem
Find span of stock prices using monotonic stack.