Ways to decode
Mediumdynamic programmingstring
Letters were encoded as numbers: A = 1, B = 2, … Z = 26. Given a digit string s, return the number of ways to decode it. A lone zero maps to nothing, and 06 is not 6.
Example 1
Input: s = "12" Output: 2
AB or L.
Example 2
Input: s = "226" Output: 3
Example 3
Input: s = "06" Output: 0
Constraints
- 1 ≤ s.length ≤ 100
- Digits only
Submit checks your solution against 10 tests, including hidden ones.
/**
* @param {string} s
* @return {int}
*/
function numDecodings(s) {
}