Find the K-Beauty of a Number
The k-beauty of an integer num is defined as the number of substrings of num when it is read as a string that meet the following conditions:
- It has a length of
k. - It is a divisor of
num.
Given integers num and k, return the k-beauty of num.
Note:
- Leading zeros are allowed.
0is not a divisor of any value.
A substring is a contiguous sequence of characters in a string.
Example 1
Input
num = 240, k = 2Output
2The substrings of length 2 are "24" and "40", and both 24 and 40 divide 240.
Example 2
Input
num = 430043, k = 2Output
2The substrings of length 2 are "43", "30", "00", "04", and "43", and only the two occurrences of 43 divide 430043.
Constraints
- 1 <= num <= 10^9
- 1 <= k <= num.length (taking num as a string)