Letter Combinations of a Phone Number (LeetCode 17) asks you to list every letter string a sequence of keypad digits could spell. On the classic phone keypad each digit from 2 to 9 prints a few letters — 2 is abc, 3 is def, 4 is ghi, and so on up to 9 (wxyz) — the same layout that once let you type words on a number pad. Given a digit string you return every combination formed by choosing one letter for each digit, so 23 produces the nine strings ad, ae, af, bd, be, bf, cd, ce, cf. Most digits map to three letters, but 7 (pqrs) and 9 (wxyz) map to four, and 0 and 1 map to none.
phoneLetterCombos(digits) // a string of keypad digits -> an array of letter strings
phoneLetterCombos("23");
// ["ad","ae","af","bd","be","bf","cd","ce","cf"] (9 combinations, any order)
phoneLetterCombos("2");
// ["a","b","c"]
phoneLetterCombos("");
// [] (empty input -> empty array, not [""])
2→abc, 3→def, 4→ghi, 5→jkl, 6→mno, 7→pqrs, 8→tuv, 9→wxyz.7 and 9 each map to four letters; every other digit maps to three. Do not hard-code three letters per digit.0 and 1 print no letters and will not appear in the input, so you do not need to handle them.phoneLetterCombos("") returns [], an empty array — not [""], a list holding one empty string.27 has 3 × 4 = 12.