Letter Combinations, traced one call at a time

Call backtrack(i) is in charge of digit i. It tries every letter on that key, and for each one asks backtrack(i + 1) to handle the next digit. The tree has one level per digit and one branch per letter.

Try:
CALL
1 / 1

Code

The highlighted line runs next. The pill shows the live values in the running call.

Recursion tree

Hover a combination in res to find its call · edges show the letter picked

not called yet running now paused, waiting on a child call full combination (saved) finished

Call stack

Top frame runs; the rest are paused

Variables

keypad current key and letter

digits → path the letter picked for each digit

res

Keyboard: ← → step, Space play or pause. Use 1 to 3 digits from 2 to 9. Keys 7 and 9 have four letters, so they make the tree wider.