We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cdd824c commit f3d6104Copy full SHA for f3d6104
C++/decode-ways-ii.cpp
@@ -8,7 +8,7 @@ class Solution {
8
static const int W = 3;
9
vector<long long> dp(W);
10
dp[0] = 1;
11
- dp[1] = s[0] == '*' ? 9 : (s[0] != '0' ? 1 : 0);
+ dp[1] = s[0] == '*' ? 9 : (s[0] != '0' ? dp[0] : 0);
12
for (int i = 1; i < s.length(); ++i) {
13
if (s[i] == '*') {
14
dp[(i + 1) % W] = 9 * dp[i % W];
0 commit comments