fix: updated problem output since the numbers of combinations could be very high.

This commit is contained in:
2026-05-18 16:34:33 -03:00
parent c85571e157
commit c58f6e4aeb
10 changed files with 23 additions and 7 deletions

View File

@@ -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()