Problem 907 · Medium

Sum of Subarray Minimums

Add up the smallest value of every contiguous piece of a list, reporting the total modulo a large prime. The visual draws each element's span of dominance using a monotonic stack.

Open the interactive visualisation