Expand a Feature Phone Digit String Into Every Letter Sequence

Last updated: November 29, 2026

Quick Overview

On an old T9 keypad each digit 2 to 9 maps to three or four letters. Given a digit string, return every letter string it could represent.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


On an old T9 keypad each digit 2 to 9 maps to three or four letters. Given a digit string, return every letter string it could represent.

A classic Google phone-screen opener, here tied to legacy T9 input support in Android. The interviewer checks clean recursion over positions, correct handling of empty input, and an honest complexity bound.

What the Interviewer Expects
  • Maps each digit to its letters with a lookup table
  • Builds strings position by position with recursion or an iterative product
  • Returns an empty list for empty input (confirm with the interviewer)
  • States O(4^n * n) time
  • Mentions handling of digits 0 and 1
Key Topics to Cover
Backtracking
Cartesian product
Recursion
String building
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you rank these expansions against a dictionary to suggest words?
  • How would you prune expansions that are not prefixes of any dictionary word?
  • Write the iterative version without recursion.
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: string of digits 2 to 9, for example "23".
  • Output: every letter combination, for example ad ae af bd be bf cd ce cf.
  • Empty input returns an empty list (the common convention, but conf...
High-Level Design

Keep a table: 2 -> abc, 3 -> def, ..., 7 -> pqrs, 9 -> wxyz. Recurse over the index of the digit string. At index i, loop over the letters for digits[i], append one to the path, recurse to i + 1, th...


Submit Your Answer
Markdown supported