
Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
If we know the current number has d digits, how many digits can the previous number have?
Is there a quick way of calculating the number of possibilities for the previous number if we know that it must have less than or equal to d digits? Try to do some pre-processing.