Jobs
Interviews

Solve Phone Keypad Letter Combinations using Python Language

Solve Phone Keypad Letter Combinations using Python to enhance your skills with python coding practice , master coding concepts, and prepare for interviews with practical exercises and detailed solutions.

Phone Keypad Letter Combinations

Difficulty : Easy

Categories :

  • Backtracking

Given a string s containing only digits (0-9), find all possible letter combinations that the number could represent on a phone keypad (like old mobile phones). The mapping is:

  • 2 -> 'abc'
  • 3 -> 'def'
  • 4 -> 'ghi'
  • 5 -> 'jkl'
  • 6 -> 'mno'
  • 7 -> 'pqrs'
  • 8 -> 'tuv'
  • 9 -> 'wxyz'

Return all possible combinations in lexicographical order.

Constraints:

  • 0 ≤ s.length ≤ 4
  • s contains only digits from 2-9

Examples:

Input: s = "23"
Output: ["ad","ae","af","bd","be","bf","cd","ce","cf"]
Explanation: All combinations of letters for '2' (abc) and '3' (def)
Input: s = "5"
Output: ["j","k","l"]
Explanation: All possible letters for '5'

Coding works best on a laptop or desktop, with a keyboard and a wider editor. You can read the problem here and solve it there.

Problem Solving

Input

What You'll Find Here

Interactive Exercises Practice coding with problems designed for beginners and experts.

Step-by-Step Solutions Understand every step of the solution process.

Real-World Scenarios Apply your skills to real-world problems and boost your confidence.

Choose from the following categories