I am using JAVA to code here, I have encountered this situation several times, so asking,
After coding the problem on my IDE and getting the basic test cases provided in problem, successfully getting passed, I submit the code.
But it gives me wrong answer or partially correct answer.
My understanding is that there is some test case, which I am not able to think of , is not getting passed.
But how do we proceed further in such situations ?
Example: SPREAD2 in SnackDown Qualifier round.
My code:
//to determine in how many days information will be spread out
/*ex: array:
2 1 1 5 5 5 5
will take 2 days to spread info to all 7 people*/
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException{
try {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0) {
int i=0;
int size = sc.nextInt();
int[] arr = new int[size];
for(i=0;i<size;i++) {
arr[i] = sc.nextInt();
}
int count=0,sum=0,temp=0,rem=size;
i=0;
while(rem>0) {
sum=0;
for(int j=0;j<=temp;j++) {
sum += arr[j];
}
i += sum;count++;
rem = size-i-1;
temp = sum;
}
System.out.println(count);
}
}catch(Exception e) {
System.out.println("exception is "+e);
return ;
}
}
}