Your question is Phone Number Combinations Recursion. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
The Uber app may need to generate keypad-style text suggestions from a sequence of digits. Given a string containing digits from 2 through 9, return every possible letter combination represented by those digits using the standard phone keypad mapping.
Use a recursive backtracking algorithm. The result must preserve keypad order: choices for each digit should be explored from left to right. Return an empty list when the input string is empty.
Implement letter_combinations(digits), where digits is a string and the return value is a list of strings. Each output string must contain exactly one letter for every input digit, with letters selected from the corresponding keypad group.
Mapping: 2 = abc, 3 = def, 4 = ghi, 5 = jkl, 6 = mno, 7 = pqrs, 8 = tuv, 9 = wxyz.
def letter_combinations(digits):