On a phone keypad, digits 2-9 each map to a set of letters: 2=abc, 3=def, 4=ghi, 5=jkl, 6=mno, 7=pqrs, 8=tuv, 9=wxyz. Given a string of such digits, generate every letter combination it could represent.
This entry exposes the recursive helper directly. Call dfs(startIndex, path, res, digits) to extend path by choosing one letter for digit digits[startIndex], appending complete combinations to res when startIndex reaches digits.length.
Input
startIndex: current digit position
path: characters chosen so far
res: accumulator for completed combinations
digits: the digit string (or array)
Output
Mutates res to contain every combination; the function itself returns nothing meaningful.
Constraints
Digits use only 2-9.
At each level, branch over every letter mapped to the current digit.