Skip to content

Commit 6994501

Browse files
committed
Fixed idea
1 parent 035d838 commit 6994501

File tree

1 file changed

+4
-4
lines changed
  • src/main/java/g3601_3700/s3698_split_array_with_minimum_difference

1 file changed

+4
-4
lines changed

src/main/java/g3601_3700/s3698_split_array_with_minimum_difference/Solution.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public long splitArray(int[] nums) {
77
int i = 1;
88
int n = nums.length;
99
long suml = nums[0];
10-
long sumr = 0;
10+
long sumr;
1111
while (i < n && nums[i] > nums[i - 1]) {
1212
suml += nums[i];
1313
i++;
@@ -28,10 +28,10 @@ public long splitArray(int[] nums) {
2828
if (suml <= sumr) {
2929
return sumr - suml;
3030
} else {
31-
if (suml - sumr - 2 * pivot > 0) {
32-
return suml - sumr - 2 * pivot;
31+
if (suml - sumr - 2L * pivot > 0) {
32+
return suml - sumr - 2L * pivot;
3333
} else {
34-
return Math.min(suml - sumr, Math.abs(suml - sumr - 2 * pivot));
34+
return Math.min(suml - sumr, Math.abs(suml - sumr - 2L * pivot));
3535
}
3636
}
3737
}

0 commit comments

Comments
 (0)