Problem · String

Letter Combinations of a Phone Number

Learn this problem
MediumAtlassian logoAtlassianFULLTIMEOA

Problem statement

Digits 2 through 9 map to letters as on a telephone keypad. Return every string formed by choosing one mapped letter for each input digit.

Return an empty list for an empty input, and otherwise return combinations in lexicographic keypad order.

Function

letterCombinations(digits: String) → String[]

Examples

Example 1

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

Choose one of abc for 2 and one of def for 3.

Constraints

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

More Atlassian problems

drafts saved locally
public String[] letterCombinations(String digits) {
  // Write your code here.
}
digits"23"
expected["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]
checking account