dsa · medium

Letter Combinations of a Phone Number

A phone keypad maps digits to letters:

Arguments

Given a string digits of digits 2-9, return every letter combination those digits could represent, in any order. Return [] if digits is empty.

Example

"23"["ad","ae","af","bd","be","bf","cd","ce","cf"].

""[].

"2"["a","b","c"].

Constraints

0 <= digits.length <= 4 digits[i] is a digit in the range ["2", "9"]

Examples

Example 1

Input:
"23"

Expected:
["ad","ae","af","bd","be","bf","cd","ce","cf"]

Example 2

Input:
""

Expected:
[]

Example 3

Input:
"2"

Expected:
["a","b","c"]

Open in the Dojo editor