Restore The Array
A program was supposed to print an array of integers. The program forgot to print whitespaces, so the array is printed as a string of digits s. All we know is that every integer in the array was in the range [1, k] and there are no leading zeros in the array.
Given the string s and the integer k, return the number of possible arrays that could have been printed as s using the mentioned program. Since the answer may be very large, return it modulo 10^9 + 7.
Example 1
Input
s = "1000", k = 10000Output
1The only possible array is [1000].
Example 2
Input
s = "1000", k = 10Output
0There cannot be an array that was printed this way and has all integers >= 1 and <= 10.
Constraints
- 1 <= s.length <= 10^5
- s consists of only digits and does not contain leading zeros.
- 1 <= k <= 10^9