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.
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.