Knight Dialer
A medium-tier problem at 61% community acceptance, tagged with Dynamic Programming. Reported in interviews at Bridgewater Associates and 1 others.
Knight Dialer is the medium-difficulty DP problem that looks deceptively simple until you realize the constraint that kills a greedy approach. You're given a phone dial pad, a knight chess piece, and a number of moves. The goal is to count all possible numbers the knight can dial. Bridgewater Associates and Snap have both asked this one. The 61% acceptance rate signals a tricky transition from brute force to the actual DP solution. Most candidates get stuck thinking about the knight's movement without recognizing the state-transition pattern underneath.
Companies that ask "Knight Dialer"
Knight Dialer is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code.
Get StealthCoderThe key insight is that this isn't about simulating knight moves at all. It's about counting paths, which means dynamic programming on the current position and remaining moves. You need to precompute which digits a knight can reach from each digit on a phone pad (0-9), then build a DP table where dp[i][j] represents the number of distinct sequences of length i starting or ending at digit j. The mistake most people make is trying to optimize the knight movement itself or overthinking the adjacency graph. The actual work is recognizing that each move extends all active paths independently. Once you map the valid transitions from each digit, the DP recurrence becomes straightforward. If you blank on the digit-to-digit connectivity on a real assessment, StealthCoder surfaces the solution in seconds and you avoid the 10-minute debugging spiral.
Pattern tags
You know the problem.
Make sure you actually pass it.
Knight Dialer recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Knight Dialer interview FAQ
How hard is Knight Dialer really compared to other DP problems?+
It's less about DP complexity and more about the phone pad constraint. If you know the valid knight moves between digits, the DP is basic. Most of the difficulty is catching that you need to precompute the adjacency map correctly. The 61% acceptance rate reflects people getting the movement logic wrong, not the recurrence.
Is this still asked at Snap and Bridgewater?+
Both companies have reported asking it. It's a classic medium-difficulty screening problem because it tests whether you can abstract a spatial problem into a state-transition one. The problem hasn't aged out, and medium DP is still fair game in their rounds.
What's the trick to not overthinking the knight movement?+
Don't simulate the knight. Hardcode which digits a knight can reach from each digit on a 3x4 phone pad. Once you have that graph, you're just doing standard DP: for each move, sum up the paths from all predecessors. Treat it as a transition counting problem, not a geometry problem.
How does this relate to graph DP and path counting?+
Knight Dialer is a path-counting problem on a small, fixed graph (10 nodes, the digits). Each edge weight is 1. DP lets you count all paths of length n efficiently without enumerating them. It's the same pattern as climbing stairs or coin change, just wrapped in a chess piece context.
Can I brute force this or do I need DP?+
Brute force (DFS/backtracking) works for small n but fails at large n because the number of paths grows exponentially. DP caches results by position and move count, cutting the work from exponential to O(n * 10). For n in the hundreds or thousands, DP is essential. Brute force hints you missed the pattern.
Want the actual problem statement? View "Knight Dialer" on LeetCode →