Skip to content

Commit a5d0947

Browse files
committed
Fixed style
1 parent 9a0d13d commit a5d0947

File tree

2 files changed

+15
-7
lines changed
  • src/main/java/g3201_3300

2 files changed

+15
-7
lines changed

src/main/java/g3201_3300/s3208_alternating_groups_ii/Solution.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
public class Solution {
66
public int numberOfAlternatingGroups(int[] colors, int k) {
7-
int i = 0, len = 0, total = 0;
7+
int i = 0;
8+
int len = 0;
9+
int total = 0;
810
while (i < colors.length - 1) {
911
int j = i + 1;
1012
if (colors[j] != colors[i]) {
@@ -14,7 +16,9 @@ public int numberOfAlternatingGroups(int[] colors, int k) {
1416
j++;
1517
len++;
1618
}
17-
if (j == colors.length) break;
19+
if (j == colors.length) {
20+
break;
21+
}
1822
total += Math.max(0, (len - k + 1));
1923
}
2024
i = j;
@@ -30,7 +34,9 @@ public int numberOfAlternatingGroups(int[] colors, int k) {
3034
j++;
3135
len++;
3236
}
33-
if (j >= k) len -= (j - k + 1);
37+
if (j >= k) {
38+
len -= (j - k + 1);
39+
}
3440
}
3541
total += Math.max(0, (len - k + 1));
3642
return total;

src/main/java/g3201_3300/s3212_count_submatrices_with_equal_frequency_of_x_and_y/Solution.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
public class Solution {
66
public int numberOfSubmatrices(char[][] grid) {
7-
int m = grid.length, n = grid[0].length, ans = 0;
7+
int m = grid.length;
8+
int n = grid[0].length;
9+
int ans = 0;
810
int[][] row = new int[n][2];
9-
for (int i = 0; i < m; i++) {
11+
for (char[] chars : grid) {
1012
int[] count = new int[2];
1113
for (int j = 0; j < n; j++) {
12-
if (grid[i][j] != '.') {
13-
count[grid[i][j] - 'X']++;
14+
if (chars[j] != '.') {
15+
count[chars[j] - 'X']++;
1416
}
1517
row[j][0] += count[0];
1618
row[j][1] += count[1];

0 commit comments

Comments
 (0)