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 stack top
Calculate span: current index - top of stack index
Push current day index onto stack
Repeat for all days
Return spans array
We use a stack to keep track of indices of days with higher prices. For each day, we pop days with lower or equal prices, then calculate the span as the difference between current day and last higher price day.