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: current index - top of stack index
Push current day index onto stack
Repeat for all days
Return span array
We use a stack to keep indexes of days with higher prices. For each day, we pop days with lower or equal prices, then calculate span using the top of stack.
