classSolution { public: intnumDecodings(string s){ int n = s.size(); s = "0" + s; int b = 1, a = s[1] == '0' ? 0 : 1; for (int i = 2; i <= n; ++i) { int res = 0; if (s[i] != '0') res += a; int t = (s[i - 1] - '0') * 10 + s[i] - '0'; if (s[i - 1] != '0' && t >= 1 && t <= 26) res += b; b = a, a = res; } return a; } };