You are given:
digits
consisting of characters
'2'
–
'9'
.
words
(dictionary).
Use the classic phone keypad mapping:
2 -> abc
,
3 -> def
,
4 -> ghi
,
5 -> jkl
,
6 -> mno
,
7 -> pqrs
,
8 -> tuv
,
9 -> wxyz
A word matches digits if:
len(digits)
, and
i
, the
i
-th character of the word is one of the letters mapped from
digits[i]
.
Return all words from words that match digits.
digits: string
,
words: list[string]
list[string]
containing all matching words (any order is acceptable).
1 <= len(digits) <= 20
0 <= len(words) <= 2 * 10^5
a
–
z
and has length up to 20.
digits = "8733"
,
words = ["tree", "used", "free", "true"]
→ output could be
["tree", "used"]
.