Problem
A message of capital letters was encoded with A → "1", B → "2", ..., Z → "26", then the digits were joined together. Given the digit string s, return how many different messages it could have come from. A code never has a leading zero, so "06" is not a valid letter.
Example 1
- Input
- s = "12"
- Output
- 2
- Why
- "AB" or "L"
Example 2
- Input
- s = "226"
- Output
- 3
- Why
- "BZ", "VF", "BBF"
Example 3
- Input
- s = "06"
- Output
- 0
- Why
- no letter starts with 0
Example 4
- Input
- s = "11106"
- Output
- 2
- Why
- 1 1 10 6, 11 10 6
Constraints
1 <= s.length <= 100s contains only digits.The answer fits in a 32-bit integer.