Problems > Total Digit Sum in a Range > Editorial

Total Digit Sum in a Range — Solution & Editorial

Back to the Problem

Digit DP returning a PAIR (count, sum-of-digitsums) per state: when placing digit d over c suffixes, it adds sum_suffix + d·c. Combine over both bounds.

Complexity: O(digits · 10)