Skip to content

Jeffma0103/Letter-Combinations-of-a-Phone-Number

Repository files navigation

Letter-Combinations-of-a-Phone-Number

Solution of Letter Combinations of a Phone Number

Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order.

A mapping of digits to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.

ex1:

Input:
digits = "23"

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

ex2:

Input:
digits = "2"

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

想法

  • 設定一個 phone 字典對應數字與字母的關係
  • 設立一個函數 run 進行字母的遍歷,加入字母可能的配對

About

Solution of Letter Combinations of a Phone Number

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages