#3855

Sum of K-Digit Numbers in a Range

candidate master · 1440 · lc hard +32 · 49.9% accepted · 37 likes · top 37%

Description

Given three integers l, r, and k, construct all possible k-digit integers where each digit is independently chosen from the range [l, r] (leading zeros are allowed when 0 is in the range). Return the sum of all such integers modulo 109 + 7.

Code

1
2
3