91. Decode Ways
Practice Decode Ways for free on NudgeCode: Medium, Dynamic Programming pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Letters are encoded as numbers: A = 1, B = 2, ..., Z = 26. Given a string of digits s, return how many ways it can be split into pieces that each map to a letter. A piece cannot have a leading zero, so "06" is not a valid piece. Return 0 if no split works.
Example
s = "226" -> 3 (2 2 6, 22 6, 2 26)
s = "06" -> 0
Constraints
- 1 <= s.length <= 100
scontains only digits