Dodomeki
Sign in

95. Phone Keypad Letters

Medium

A phone keypad maps 2 to abc, 3 to def, 4 to ghi, 5 to jkl, 6 to mno, 7 to pqrs, 8 to tuv, and 9 to wxyz. Given a sequence of digits from 2 to 9, return all words that can be formed, preserving the order of the digits. If the sequence is empty, return an empty list.

Example 1
Input: digitos = "27"
Output: ["ap", "aq", "ar", "as", "bp", "bq", "br", "bs", "cp", "cq", "cr", "cs"]
Example 2
Input: digitos = ""
Output: []
Constraints
  • 0 <= digitos.length <= 4
  • Each character of digitos is between 2 and 9.
BacktrackingStrings
Caso 1
digitos =
"27"
Expected =
["ap","aq","ar","as","bp","bq","br","bs","cp","cq","cr","cs"]
Caso 2
digitos =
""
Expected =
[]

Run checks these 2 cases. Submit runs all 6, including hidden ones.