Skip to content

Commit d450576

Browse files
committed
Fixed style
1 parent ef51f16 commit d450576

File tree

2 files changed

+20
-9
lines changed
  • src/main/java/g3301_3400

2 files changed

+20
-9
lines changed

src/main/java/g3301_3400/s3355_zero_array_transformation_i/Solution.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,30 @@ public class Solution {
66
public boolean isZeroArray(int[] nums, int[][] queries) {
77
int n = nums.length;
88
int sum = 0;
9-
for (int num : nums) sum += num;
10-
if (sum == 0) return true;
9+
for (int num : nums) {
10+
sum += num;
11+
}
12+
if (sum == 0) {
13+
return true;
14+
}
1115
int[] diff = new int[n + 1];
1216
for (int[] q : queries) {
1317
int low = q[0];
1418
int high = q[1];
1519
diff[low] -= 1;
16-
if (high + 1 < n) diff[high + 1] += 1;
20+
if (high + 1 < n) {
21+
diff[high + 1] += 1;
22+
}
1723
}
1824
for (int i = 0; i < n; i++) {
19-
if (i > 0) diff[i] += diff[i - 1];
25+
if (i > 0) {
26+
diff[i] += diff[i - 1];
27+
}
2028
nums[i] += diff[i];
2129
sum += diff[i];
22-
if (nums[i] > 0) return false;
30+
if (nums[i] > 0) {
31+
return false;
32+
}
2333
}
2434
return sum <= 0;
2535
}

src/main/java/g3301_3400/s3357_minimize_the_maximum_adjacent_element_difference/Solution.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
public class Solution {
66
public int minDifference(int[] nums) {
77
int n = nums.length;
8-
int max_adj = 0;
8+
int maxAdj = 0;
99
int mina = Integer.MAX_VALUE;
1010
int maxb = Integer.MIN_VALUE;
1111
for (int i = 0; i < n - 1; ++i) {
1212
int a = nums[i];
1313
int b = nums[i + 1];
1414
if (a > 0 && b > 0) {
15-
max_adj = Math.max(max_adj, Math.abs(a - b));
15+
maxAdj = Math.max(maxAdj, Math.abs(a - b));
1616
} else if (a > 0 || b > 0) {
1717
mina = Math.min(mina, Math.max(a, b));
1818
maxb = Math.max(maxb, Math.max(a, b));
@@ -28,7 +28,8 @@ public int minDifference(int[] nums) {
2828
while (j < n && nums[j] == -1) {
2929
j++;
3030
}
31-
int a = Integer.MAX_VALUE, b = Integer.MIN_VALUE;
31+
int a = Integer.MAX_VALUE;
32+
int b = Integer.MIN_VALUE;
3233
if (i > 0) {
3334
a = Math.min(a, nums[i - 1]);
3435
b = Math.max(b, nums[i - 1]);
@@ -50,6 +51,6 @@ public int minDifference(int[] nums) {
5051
}
5152
}
5253
}
53-
return Math.max(max_adj, (res + 1) / 2);
54+
return Math.max(maxAdj, (res + 1) / 2);
5455
}
5556
}

0 commit comments

Comments
 (0)