Practice Knight Dialer
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Use the phone keypad with rows 1 2 3, then 4 5 6, then 7 8 9, and finally 0 below 8. A chess knight moves two cells in one axis and one in the other, and may land only on digit cells. Start on any digit and make n - 1 valid jumps, recording the starting digit and each landing digit. Return the number of distinct length-n digit strings modulo 10^9 + 7.
Source: Knight Dialer on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
n = 1
10
# Example 2
n = 2
20
# Example 3
n = 3131
136006598
Constraints
Related LeetCode Problems
Practice more problems similar to Knight Dialer.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.