更新0018JAVA版本

用例有一个是[1000000000,1000000000,1000000000,1000000000] -294967296
如果用int会越界,所以修改为long
This commit is contained in:
chenwingsing
2022-07-02 21:58:17 +08:00
committed by GitHub
parent 23cc66346c
commit 889256a378

View File

@ -153,7 +153,7 @@ class Solution {
int left = j + 1;
int right = nums.length - 1;
while (right > left) {
int sum = nums[i] + nums[j] + nums[left] + nums[right];
long sum = (long) nums[i] + nums[j] + nums[left] + nums[right];
if (sum > target) {
right--;
} else if (sum < target) {