Skip to content

Commit 10e5791

Browse files
author
alxkm
committed
checkstyle: fix formatting
1 parent ef14267 commit 10e5791

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/main/java/com/thealgorithms/others/MaximumSumOfDistinctSubarraysWithLengthK.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ public static long maximumSubarraySum(int k, int... nums) {
2929
}
3030
long masSum = 0; // Variable to store the maximum sum of distinct subarrays
3131
long currentSum = 0; // Variable to store the sum of the current subarray
32-
Set<Integer> currentSet = new HashSet<>(); // Set to track distinct elements in the current subarray
32+
Set<Integer> currentSet = new HashSet<>();// Set to track distinct elements in the current subarray
3333

3434
// Initialize the first window
3535
for (int i = 0; i < k; i++) {
3636
currentSum += nums[i];
3737
currentSet.add(nums[i]);
3838
}
3939
// If the first window contains distinct elements, update maxSum
40-
if (currentSet .size() == k) {
40+
if (currentSet.size() == k) {
4141
masSum = currentSum;
4242
}
4343
// Slide the window across the array
@@ -47,7 +47,7 @@ public static long maximumSubarraySum(int k, int... nums) {
4747
currentSum = currentSum + nums[i + k - 1];
4848
int j = i;
4949
boolean flag = false; // flag value which says that the subarray contains distinct elements
50-
while (j < i + k && currentSet .size() < k) {
50+
while (j < i + k && currentSet.size() < k) {
5151
if (nums[i - 1] == nums[j]) {
5252
flag = true;
5353
break;

src/test/java/com/thealgorithms/others/MaximumSumOfDistinctSubarraysWithLengthKTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void testMaximumSubarraySum(int expected, int k, int[] arr) {
1616
}
1717

1818
private static Stream<Arguments> inputStream() {
19-
return Stream.of(Arguments.of(15, 3, new int[] {1, 5, 4, 2, 9, 9, 9}), Arguments.of(0, 3, new int[] {4, 4, 4}), Arguments.of(12, 3, new int[] {9, 9, 9, 1, 2, 3}), Arguments.of(0, 0, new int[] {9, 9, 9}), Arguments.of(0, 5, new int[] {9, 9, 9}), Arguments.of(9, 1, new int[] {9, 2, 3, 7}), Arguments.of(15, 5, new int[] {1, 2, 3, 4, 5}), Arguments.of(6, 3, new int[] {-1, 2, 3, 1, -2, 4}),
20-
Arguments.of(10, 1, new int[] {10}), Arguments.of(0, 2, new int[] {7, 7, 7, 7}), Arguments.of(0, 3, new int[] {}), Arguments.of(0, 10, new int[] {1, 2, 3}));
19+
return Stream.of(Arguments.of(15, 3, new int[] {1, 5, 4, 2, 9, 9, 9}), Arguments.of(0, 3, new int[] {4, 4, 4}), Arguments.of(12, 3, new int[] {9, 9, 9, 1, 2, 3}), Arguments.of(0, 0, new int[] {9, 9, 9}), Arguments.of(0, 5, new int[] {9, 9, 9}), Arguments.of(9, 1, new int[] {9, 2, 3, 7}),
20+
Arguments.of(15, 5, new int[] {1, 2, 3, 4, 5}), Arguments.of(6, 3, new int[] {-1, 2, 3, 1, -2, 4}), Arguments.of(10, 1, new int[] {10}), Arguments.of(0, 2, new int[] {7, 7, 7, 7}), Arguments.of(0, 3, new int[] {}), Arguments.of(0, 10, new int[] {1, 2, 3}));
2121
}
2222
}

0 commit comments

Comments
 (0)