#17

Letter Combinations of a Phone Number

specialist · 625 · lc medium +29 · verified · 65.6% accepted · 20,830 likes · top 70%

play →

Description

Digits 2 through 9 each map to a set of letters as on a telephone keypad (digit 1 maps to nothing). Given a digit string, return all possible letter strings it could represent in any order.

Example 1:

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

Example 2:

Input: digits = "2"
Output: ["a","b","c"]

Code

1
2
3