A chess knight stands on a phone keypad (digits 1-9 in three rows, 0 centered below them). It can only stand on numeric keys and moves like a knight: two squares in one direction and one square perpendicular. Given an integer n, return how many distinct phone numbers of length n you can dial by placing the knight on any numeric key and making n - 1 valid knight jumps. Return the answer modulo 10^9 + 7.
A chess knight stands on a phone keypad (digits 1-9 in three rows, 0 centered below them). It can only stand on numeric keys and moves like a knight: two squares in one direction and one square perpendicular. Given an integer n, return how many distinct phone numbers of length n you can dial by placing the knight on any numeric key and making n - 1 valid knight jumps. Return the answer modulo 10^9 + 7.
Example 1:
Input: {"n":1}
Output: 10
Constraints:
1≤n≤5000
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"n":1}
Every key is a valid 1-digit number, so each key starts with a count of 1 path ending on it.