Decode Ways
Hard · Dynamic Programming
Letters are encoded as numbers: "A" is "1", "B" is "2", ... "Z" is "26". Write a function numDecodings that returns how many ways a non-empty digit string s can be decoded back into letters.
A code cannot start with 0: "06" is not a valid code for "F", and a lone "0" is invalid. If the string cannot be decoded at all, return 0.
Next: Word Break