mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 19:44:45 +08:00
更新0018JAVA版本
用例有一个是[1000000000,1000000000,1000000000,1000000000] -294967296 如果用int会越界,所以修改为long
This commit is contained in:
@ -153,7 +153,7 @@ class Solution {
|
|||||||
int left = j + 1;
|
int left = j + 1;
|
||||||
int right = nums.length - 1;
|
int right = nums.length - 1;
|
||||||
while (right > left) {
|
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) {
|
if (sum > target) {
|
||||||
right--;
|
right--;
|
||||||
} else if (sum < target) {
|
} else if (sum < target) {
|
||||||
|
Reference in New Issue
Block a user