Problem 3578 · Medium

Count Partitions With Max-Min Difference at Most K

Each prefix sums the partition counts of every start whose part keeps max minus min within k, stopping as soon as that gap is exceeded.

Open the interactive visualisation