framed logic according to my understanding and wrote the program to find the minimum no possible between 2 students of 4 books
But testcase says wrong please help
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scan=new Scanner(System.in);
int T=scan.nextInt();
for(int j=0;j<T&&T<50;j++)
{
int N=scan.nextInt();
int M=scan.nextInt();
int[] array= new int[N];
for(int i=0;i<array.length;i++)
{
array[i]=scan.nextInt();
}
if(M<=50&&N<=100)
{
int min=bookallocation(N,M,array);
System.out.println(min);
}
}
}
public static int bookallocation(int books,int students,int [] array)
{
int[] temp=new int[students];
int j=0;
for(int i=0;i<students;)
{
j=i;
for(;j<=books-students+i;j++)
{
temp[i]=temp[i]+array[j];
}
i++;
}
return temp[0];
}
}