Is there any way we can return multiple values in a java function of int data type?
Let me share a code snippet of Maximum of all subarrays of size k
Sample Input 0
9 3 1 2 3 1 4 5 2 3 6
Sample Output 0
[3, 3, 4, 5, 5, 5, 6] // Can we get this output with above constraints?
public static int max_sum(int N, List<Integer> arr, int K) {
int j, max=0;
for (int i = 0; i <= N - K; i++) {
max = arr.get(i);
for (j = 1; j < K; j++) {
if (arr.get(i + j) > max)
max = arr.get(i + j);
}
}
return max;
}
int[]
?