```
/**
* @param {string} s
* @return {number}
*/
var numDecodings = function(s) {
var i, cur = 0, prev = 1, prev2 = 0;
for (i = s.length - 1; i >= 0; i--) {
if (s[i] === '0') {
cur = 0;
} else {
cur = prev;
if (parseInt(s[i] + s[i + 1]) <= 26)
cur += prev2;
}
prev2 = prev; prev = cur;
}
return cur;
};
```