Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Let f(n, l, r) denotes the number of integers from 1 to n with the sum of digits between l and r.
The answer is f(num2, min_sum, max_sum) - f(num-1, min_sum, max_sum).
You can calculate f(n, l, r) using digit dp.