fix: updated problem output since the numbers of combinations could be very high.
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
typedef long long ll;
|
||||
using namespace std;
|
||||
|
||||
const int MOD = 1e9 + 7;
|
||||
|
||||
ll numDecodings(string s)
|
||||
{
|
||||
if (s[0] == '0')
|
||||
@@ -36,15 +38,17 @@ ll numDecodings(string s)
|
||||
if (current != '0')
|
||||
{
|
||||
dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
|
||||
dp[i][0] %= MOD;
|
||||
}
|
||||
|
||||
int code = stoi(aux);
|
||||
if (10 <= code && code <= 26)
|
||||
{
|
||||
dp[i][1] = dp[i - 2][0] + dp[i - 2][1];
|
||||
dp[i][1] %= MOD;
|
||||
}
|
||||
}
|
||||
return dp[N][0] + dp[N][1];
|
||||
return (dp[N][0] + dp[N][1]) % MOD;
|
||||
}
|
||||
|
||||
int main()
|
||||
|
||||
Reference in New Issue
Block a user