A message containing letters from A-Z
is being encoded to numbers using the following mapping:
1 | 'A' -> 1 |
Given a non-empty string containing only digits, determine the total number of ways to decode it.
The answer is guaranteed to fit in a 32-bit integer.
Example 1:
1 | Input: s = "12" |
Example 2:
1 | Input: s = "226" |
Example 3:
1 | Input: s = "0" |
Example 4:
1 | Input: s = "1" |
Constraints:
1 <= s.length <= 100
s
contains only digits and may contain leading zero(s).