Letter Combinations of a Phone Number

TopicDifficultyCompanies
Backtracking
HARD
Google

Given a string, str , containing digits from 2 - 9 inclusive, write a program to return all the possible letter combinations that the number could represent.

Problem Note

  • Your answer could be in any order you want.
  • A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.

problem

Example

Input: "24" 
Output: ["ag","ah","ai","bg","bh","bi","cg","ch","ci"]

Code Editor

Practice and Learn

Best way to learn is through solving real problems. Practice this problem in this code editor.