← Questions

Count non-decreasing arrays with given digit sums

0
MicrosoftCodingLast asked Aug 2026

You get an array requiredSum of length n. Count arrays result of length n that are non-decreasing and where the digit sum of result[i] equals requiredSum[i] for every i, within the value bound the problem gives; return the count modulo a large prime. Explain the dynamic programming over positions and values and how prefix sums keep it fast.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding