Bölüm 4 · SimülatörStock Span Simulator? ← Bölüm 4 Prices Load Example Random Previous Next Auto Run Reset CancelReady.Monotonic StackTOP CloseStock Span SimulatorThe span of day i is the number of consecutive days up to and including day i whose price is less than or equal to the price on day i.How to useType 1–10 positive Prices separated by commas and press Load, or use Example / Random.Next / Previous move one step; Auto Run plays all steps; Reset returns to the start; Cancel stops playback.Monotonic stack algorithmFor each day i, pop indices while the price on top of the stack is ≤ price[i].span[i] = i + 1 if the stack is empty, otherwise i − top.Push i.The stack holds days with strictly decreasing prices. Every index is pushed and popped at most once, so the whole run is O(n) time (the naive method is O(n²)).