Back to problems

Count ways to decode digit string

Algorithm · Snapchat · Medium

Given a string s that contains only the decimal digits '0' through '9', consider the encoding in which the numbers $$1$$ through $$26$$ represent the letters A through Z. A decoding splits s into one or more consecutive pieces so that each piece, after being converted to an integer, belongs to the range $$1 \ldots 26$$ and does not begin with 0. For example, a two-character piece is usable only when its value is between $$10$$ and $$26$$; thus "06" and "30" are invalid.…

Checking your access…