Count Letter Decodings of a Digit String

Asked at Goldman Sachs · Coding Questions · Difficulty: Medium · Last asked Jul 11, 2025

A message made of capital letters was encoded by replacing each letter with its position in the alphabet: `A` becomes `"1"`, `B` becomes `"2"`, ..., `Z` becomes `"26"`, and the numbers were written one after another with no separators. Given only the resulting digit string, count how many different letter messages could have produced it.

Loading the problem…