A message was encoded by mapping each letter to its position in the alphabet — A to 1, B to 2, all the way to Z to 26 — and then writing the numbers down with no separators. Given the resulting string of digits, return the number of distinct ways it could be decoded back into letters. This is the classic Decode Ways counting problem: you are not asked to list the decodings, only to count them.
function stringDecodeMessage(digits: string): number;
// digits is a string of '0'–'9' characters; returns a count of valid decodings
stringDecodeMessage("12"); // 2 — "1 2" → "AB", or "12" → "L"
stringDecodeMessage("226"); // 3 — "2 2 6" → "BBF", "22 6" → "VF", "2 26" → "BZ"
stringDecodeMessage("06"); // 0 — no decoding: "0" maps to nothing, and "06" is not a valid pair
1–9. A two-digit chunk decodes only if it is 10–26. Anything outside those ranges contributes nothing."06" or "08" does not map to a letter — only "10" through "26" are valid two-digit chunks. 09 is not 9."0" has no decoding. stringDecodeMessage("0") returns 0, and any 0 that cannot be the second digit of a 10–26 pair kills every decoding that reaches it.stringDecodeMessage("") returns 1 — the empty string has exactly one decoding, the empty message. This is the base case the counting relies on; the solution explains why.