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 stack top
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
The flow shows how we use a stack to keep indexes of prices. For each price, we pop smaller or equal prices from stack, then calculate span using the top of stack or full range if stack is empty, then push current index.
