A digit string is good if the digits at even indices (0-indexed) are even and the digits at odd indices are prime (2, 3, 5 or 7). Given an integer n, return the number of good digit strings of length n, modulo 10^9 + 7. Leading zeros are allowed.
A digit string is good if the digits at even indices (0-indexed) are even and the digits at odd indices are prime (2, 3, 5 or 7). Given an integer n, return the number of good digit strings of length n, modulo 10^9 + 7. Leading zeros are allowed.
Example 1:
Input: {"n":1}
Output: 5
Constraints:
1≤n≤231−1 (LeetCode allows up to 1015; here n is a 32-bit int)
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"n":1}
A good number of length 1 has a digit choice at every index: 5 even digits at even indices, 4 primes at odd indices.
digit positions of a length-1 number (choices per slot)