Concept Flow - Stock Span Problem Using Stack
Start with empty stack
For each price in array
While stack not empty and top price <= current price
Pop from stack
Calculate span: current index - top of stack index or current index + 1 if stack empty
Push current index onto stack
Move to next price
Repeat until all prices processed
Return span array
We use a stack to keep indexes of days with higher prices. For each day, pop smaller prices, then calculate span using stack top.
