Goldman SachsOA #10
Alphanumeric Combinations
Estimated MediumJudge-ready
A digit string can be split, in order, into integers 1..26, which map to a..z. Each valid split corresponds to one word; a leading zero cannot be decoded on its own or as part of 01..09.
Input
A single line containing a digit string S. This site adds 1≤|S|≤1000 with characters only 0..9, so that the output fits within this problem's judging output limit.
Output
Output the number of valid decodings as a decimal integer; output 0 if there is no valid decoding.
Example 1
Input:
2112
Output:
5
Example 2
Input:
2101
Output:
1
Example 3
Input:
100
Output:
0
Editorial
Loading solution…