Keypad Codenames
mediumAn old door-entry system displays a numeric code, but the staff memorize codes as words using the classic phone keypad mapping (2 → abc, 3 → def, 4 → ghi, 5 → jkl, 6 → mno, 7 → pqrs, 8 → tuv, 9 → wxyz).
Given a string digits containing only characters '2'–'9', return every word the code could spell — one letter chosen per digit, in order. Return them in any order. If digits is empty, return an empty list.
Example 1
in digits = "23"
out ["ad","ae","af","bd","be","bf","cd","ce","cf"]
Each of {a,b,c} pairs with each of {d,e,f}: 3 × 3 = 9 words.
Example 2
in digits = ""
out []
Constraints
- · 0 <= len(digits) <= 4
- · digits[i] is in '2'..'9'
solution.py● loading python…
test results
Hit ▶ Run to test your code against the visible cases.