#K32852. Decode Ways - Counting Decodings
Decode Ways - Counting Decodings
Decode Ways - Counting Decodings
You are given an encoded message containing only digits. The encoding follows the mapping: \(A=1, B=2, \ldots, Z=26\). You need to determine the total number of ways to decode the message. For example, the input "12" can be decoded as "AB" (1 2) or "L" (12) resulting in 2 possible decodings.
Note that the mapping does not allow numbers with leading zeros. For instance, "06" is not a valid encoding. Use dynamic programming to solve the problem efficiently.
inputFormat
The input consists of a single line containing a non-negative string s
that represents the encoded message.
outputFormat
Output a single integer, which is the number of ways to decode the message.
## sample12
2