Medium · Backtracking

Letter Combinations of a Phone Number

Given a string digits made of the characters '2'–'9', return every letter string it could spell on a phone keypad (2 → abc, 3 → def, 4 → ghi, 5 → jkl, 6 → mno, 7 → pqrs, 8 → tuv, 9 → wxyz), in any order; if digits is empty, return an empty list.

Examples

Example 1

digits = "23"

Output: 9 combos

Example 2

digits = "2"

Output: 3 combos

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Backtracking problems