Number of Beautiful Integers in the Range
You are given positive integers low, high, and k.
A number is beautiful if it meets both of the following conditions:
- The count of even digits in the number is equal to the count of odd digits.
- The number is divisible by
k.
Return the number of beautiful integers in the range [low, high].
Example 1
Input
low = 10, high = 20, k = 3Output
2There are 2 beautiful integers in the given range, 12 and 18, because each has equal counts of even and odd digits and is divisible by 3.
Example 2
Input
low = 1, high = 10, k = 1Output
1There is 1 beautiful integer in the given range, 10, because it has 1 odd digit and 1 even digit and is divisible by 1.
Constraints
- 0 < low <= high <= 10^9
- 0 < k <= 20