Letter Combinations of a Phone Number
Recognize the pattern
Brute force idea
The naive version of Letter Combinations of a Phone Number sounds like this: Not applicable — generating all combinations IS the problem. Output size is up to 4^n. That direct path helps you understand the question, but it tends to treat every possibility as brand new instead of learning from earlier steps.
Better approach
A calmer way to see Letter Combinations of a Phone Number is this: Backtracking: for each digit, try each possible letter mapping. Build the string character by character. When the string reaches input length, record it. The goal is not to be clever for its own sake, but to remember the one relationship that keeps the solution grounded as you move forward.
Key invariant
The truth you want to protect throughout Letter Combinations of a Phone Number is this: Each digit maps to 3-4 letters. At each position, try all possible letters for the current digit, then recurse for the next digit. The branching factor is the number of letters per digit. If that remains true after every update, the rest of the reasoning has a stable place to stand.
Watch out for
One easy way to drift off course in Letter Combinations of a Phone Number is this: Not handling the empty input case — return an empty array, not an array with an empty string. The fix is usually to return to the meaning of each move, not just the steps themselves.