Problem 3251 · Hard

Find the Count of Monotonic Pairs II

Count splits of each nums value into a non-decreasing and a non-increasing part, using prefix sums for large inputs.

Open the interactive visualisation