FastPrepPhone Keypad Letter Combinations
Problems/Phone Keypad Letter Combinations

Phone Keypad Letter Combinations

Google logoGoogle● MediumFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report identifies a task similar to the classic phone-keypad backtracking problem but omits input and ordering details. The judged core task matches the visible source at about 92%.

Given a string digits, return every letter combination that the digits could represent on a conventional telephone keypad.

  • 2 maps to abc, 3 to def, 4 to ghi, 5 to jkl.
  • 6 maps to mno, 7 to pqrs, 8 to tuv, and 9 to wxyz.

For this exercise, emit combinations in depth-first order, visiting each digit's mapped letters from left to right. Return an empty list for empty input.

Function

letterCombinations(digits: String) → List<String>

Examples

Example 1

digits = "23"return = ["ad","ae","af","bd","be","bf","cd","ce","cf"]

Choose one of abc for the first position and one of def for the second, following left-to-right depth-first order.

Example 2

digits = ""return = []

There is no position to assign, so the exercise returns an empty list.

Constraints

  • 0 <= digits.length <= 4
  • Every character in digits is between 2 and 9.

More Google problems

  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public List<String> letterCombinations(String digits) {
        // Write your code here.
    }
}
Checking account…