Skip to content

Commit 52b0217

Browse files
committed
Added test
1 parent 85b7dbb commit 52b0217

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/main/java/g3201_3300/s3245_alternating_groups_iii/Solution.java

-4
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ private int processQueryType1(int[] colors, TreeMap<Integer, Integer> groups, in
109109
ans -= Math.max(rightLen - groupSize + 1, 0);
110110
ans += Math.max(leftLen + rightLen - groupSize + 1, 0);
111111
}
112-
} else if (colors[0] != colors[colors.length - 1]) {
113-
// In the special case when there's a single group but the
114-
// first and last colors differ, the whole array is counted.
115-
ans = colors.length;
116112
}
117113
return ans;
118114
}

src/test/java/g3201_3300/s3245_alternating_groups_iii/SolutionTest.java

+10
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,14 @@ void numberOfAlternatingGroups2() {
2525
new int[][] {{1, 3}, {2, 3, 0}, {1, 5}}),
2626
equalTo(List.of(2, 0)));
2727
}
28+
29+
@Test
30+
void numberOfAlternatingGroups3() {
31+
assertThat(
32+
new Solution()
33+
.numberOfAlternatingGroups(
34+
new int[] {0, 0, 0, 1},
35+
new int[][] {{2, 1, 1}, {1, 3}, {2, 1, 1}, {2, 0, 1}}),
36+
equalTo(List.of(4)));
37+
}
2838
}

0 commit comments

Comments
 (0)