Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3c07d23

Browse files
Fix integer overflow by using uint64_t for dp array
1 parent 373e168 commit 3c07d23

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

‎Dynamic_Programming/518.Coin-Change-2/518.Coin-Change-2_v1.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class Solution {
22
public:
33
int change(int amount, vector<int>& coins)
44
{
5-
vector<int>dp(amount+1,0);
5+
vector<uint64_t>dp(amount+1,0);
66
dp[0] = 1;
77
for (int i=0; i<coins.size(); i++)
88
{

‎Dynamic_Programming/518.Coin-Change-2/518.Coin-Change-2_v2.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class Solution {
22
public:
33
int change(int amount, vector<int>& coins)
44
{
5-
vector<int>dp(amount+1,0);
5+
vector<uint64_t>dp(amount+1,0);
66
dp[0] = 1;
77
for (int i=0; i<coins.size(); i++)
88
{

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /