Concept Flow - Stock Span Problem Using Stack
Start with empty stack
For each day's price
While stack not empty and top price <= current price
Pop from stack
Calculate span: if stack empty -> i+1 else i - top index
Push current day index onto stack
Move to next day
Repeat until all days processed
Return span array
We use a stack to keep track of indices of days with higher prices. For each day, we pop days with prices less or equal to current, then calculate span based on stack top.
