← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Meta coding interview with a combinatorics problem on mobile keypad digit paths. Not a lot of context to go on, but it felt like a mid-level technical screen.

Questions Asked (1)

Q1

Given a mobile phone keypad, count the total number of possible N-digit number combinations you can form by moving like a chess knight across the keys.

Algorithms & Data Structures
Author's notes

I stared at this for longer than I'd like to admit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the keypad as a graph where each key is a node and knight moves define edges. Use dynamic programming to count the number of ways to reach each key for each digit length, starting from all keys for length 1 and iterating up to N.

Pro tip: Clarify the keypad layout (e.g., 3x4 grid with 0 at bottom center) and discuss how the solution can be optimized using matrix exponentiation for very large N, showing awareness of scalability.

1. Clarify the problem

Confirm the keypad layout, definition of a knight move, and whether leading zeros are allowed. Ask about constraints on N (e.g., N up to 10^9) to determine if optimization is needed.

2. Model as a graph

Represent each key as a node and precompute all valid knight moves from each key. This forms a directed graph where edges represent possible transitions.

3. Define DP recurrence

Let dp[i][k] be the number of sequences of length i ending at key k. Base case: dp[1][k] = 1 for all k. Transition: dp[i][k] = sum of dp[i-1][j] for all j that can move to k via a knight move.

4. Compute and optimize

Iterate from length 2 to N, updating dp for each key. Sum dp[N][k] over all k for the answer. For large N, use matrix exponentiation on the transition matrix to achieve O(log N) time.

5. Analyze complexity

Discuss time and space complexity: O(N * 10) for DP, or O(10^3 log N) for matrix exponentiation. Mention that the graph is sparse, so transitions are constant time per key.

Key Points to Mention

  • Graph representation of the keypad with knight moves as edges
  • Dynamic programming state definition and recurrence relation
  • Handling of base case (N=1) and summation for final answer
  • Optimization using matrix exponentiation for large N
  • Time and space complexity analysis
  • Edge cases: N=0, N=1, and keys with no outgoing moves (e.g., 5)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.