We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8ea4494 commit fc95e6bCopy full SHA for fc95e6b
src/test/java/com/thealgorithms/slidingwindow/CountNiceSubarraysTest.java
@@ -28,4 +28,29 @@ void testMultipleChoices() {
28
int[] nums = {2, 2, 1, 2, 2, 1, 2};
29
assertEquals(6, CountNiceSubarrays.countNiceSubarrays(nums, 2));
30
}
31
+
32
+ @Test
33
+ void testTrailingEvenNumbers() {
34
+ int[] nums = {1, 2, 2, 2};
35
+ assertEquals(4, CountNiceSubarrays.countNiceSubarrays(nums, 1));
36
+ }
37
38
39
+ void testMultipleWindowShrinks() {
40
+ int[] nums = {1, 1, 1, 1};
41
+ assertEquals(3, CountNiceSubarrays.countNiceSubarrays(nums, 2));
42
43
44
45
+ void testEvensBetweenOdds() {
46
+ int[] nums = {2, 1, 2, 1, 2};
47
+ assertEquals(4, CountNiceSubarrays.countNiceSubarrays(nums, 2));
48
49
50
51
+ void testShrinkWithTrailingEvens() {
52
+ int[] nums = {2, 2, 1, 2, 2, 1, 2, 2};
53
+ assertEquals(9, CountNiceSubarrays.countNiceSubarrays(nums, 2));
54
55
56
0 commit comments