Problem. A message of letters A–Z was encoded as digits with A → 1, B → 2, …, Z → 26. Given the digit string, return the number of ways to decode it.
"12" → 2 ("AB" from 1 2, "L" from 12)
"226" → 3 (2 2 6, 22 6, 2 26)
"06" → 0 ("06" isn't a valid code, and 0 alone maps to nothing)
"10" → 1 (only 10 = J)
It's lesson 12.2's climbing stairs with conditions on the steps: from position i you may take one digit if it's 1–9, or two digits if they form 10–26. The zeros are where solutions go wrong: a 0 can never stand alone, so it must be the second digit of 10 or 20.
ML context. Counting the readings of an ambiguous sequence is everywhere in sequence modelling: the number of ways an OCR or speech output can be split into symbols, the readings of a byte stream as multi-byte characters, alignments in a segmentation lattice. When each reading has a probability, the same DP sums them (the forward algorithm) or takes the best one (Viterbi, lesson 12.16); Change D shows the sum.