Skip to content

Commit

Permalink
Merge pull request youngyangyang04#2513 from JasenChao/master
Browse files Browse the repository at this point in the history
Update 0494.目标和.md
  • Loading branch information
youngyangyang04 authored May 7, 2024
2 parents 73f9904 + 7df5157 commit 3b6ac8b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion problems/0494.目标和.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public:
int sum = 0;
for (int i = 0; i < nums.size(); i++) sum += nums[i];
if (S > sum) return 0; // 此时没有方案
if ((S + sum) % 2) return 0; // 此时没有方案,两个int相加的时候要各位小心数值溢出的问题
if ((S + sum) % 2) return 0; // 此时没有方案,两个int相加的时候要格外小心数值溢出的问题
int bagSize = (S + sum) / 2; // 转变为组合总和问题,bagsize就是要求的和

// 以下为回溯法代码
Expand Down

0 comments on commit 3b6ac8b

Please sign in to comment.