Knight Dialer
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
A chess knight is placed on a phone keypad laid out as:
```
1 2 3
4 5 6
7 8 9
0
```
The knight may start on any digit and then makes exactly n - 1 knight moves (two squares in one direction and one square perpendicular), always landing on a digit key. The digits it visits, in order, form a phone number of length n.
Return how many distinct numbers of length n can be dialed this way, modulo 10^9 + 7.
Examples
Constraints
- 1 <= n <= 5000
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.