Back to DSA

Letter Combinations of a Phone Number

medium
Acceptance: 48%
BacktrackingStrings

Each digit from 2 to 9 on a telephone keypad maps to a set of letters. Given a string of such digits, return every possible letter combination the digits could produce. The output may appear in any order.

Examples

Example 1:
Input:digits = "45"
Output:["gj","gk","gl","hj","hk","hl","ij","ik","il"]
Example 2:
Input:digits = "7"
Output:["p","q","r","s"]

Hints

00:00
1234567