Skip to content

Commit 8e59e09

Browse files
authored
Update choose-numbers-from-two-arrays-in-range.cpp
1 parent b9003d8 commit 8e59e09

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

C++/choose-numbers-from-two-arrays-in-range.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ class Solution {
1818
new_dp[v - nums2[i]] = (new_dp[v - nums2[i]] + c) % MOD;
1919
}
2020
dp = move(new_dp);
21-
result = (result + dp[0]) % MOD;
21+
if (dp.count(0)) {
22+
result = (result + dp[0]) % MOD;
23+
}
2224
}
2325
return result;
2426
}

0 commit comments

Comments
 (0)