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')
|
||||
@@ -20,12 +22,14 @@ ll numDecodings(string s)
|
||||
if (current != '0')
|
||||
{
|
||||
next = dp2;
|
||||
next %= MOD;
|
||||
}
|
||||
|
||||
int code = stoi(aux);
|
||||
if (10 <= code && code <= 26)
|
||||
{
|
||||
next += dp1;
|
||||
next %= MOD;
|
||||
}
|
||||
swap(dp1, dp2);
|
||||
swap(dp2, next);
|
||||
|
||||
Reference in New Issue
Block a user