Imagine you're a forensic data analyst working with a corrupted program output! ๐ต๏ธโโ๏ธ
A program was supposed to print an array of integers, but it forgot to include spaces between the numbers. Now you have a continuous string of digits, and you need to figure out how many different ways the original array could have been structured.
The Rules:
- All integers in the original array were between
1andk(inclusive) - No number had leading zeros (so no
01,007, etc.) - The string
srepresents all numbers concatenated together
Your Mission: Count how many different valid arrays could produce the given string s.
Example: If s = "1000" and k = 10000, this could be:
โข [1, 0, 0, 0] โ (contains 0, which is not in range [1,k])
โข [10, 0, 0] โ (contains 0)
โข [100, 0] โ (contains 0)
โข [1000] โ
(valid!)
Since the answer can be very large, return it modulo 109 + 7.
Input & Output
Constraints
- 1 โค s.length โค 105
- s consists of only digits
- 1 โค k โค 109
- No leading zeros in any number of the array