My issue
My code
import java.util.*;
class Codechef
{
public static void main (String[] args)
{
Scanner read = new Scanner(System.in);
int t = read.nextInt();
for(int i=0; i<t; i++)
{
ArrayList<Integer> a = new ArrayList<Integer>();
ArrayList<Integer> b = new ArrayList<Integer>();
int n = read.nextInt();
for(int j=1; j<=n; j++){
int ele = read.nextInt();
a.add(ele);
}
for(int k=1; k<=n; k++){
int ele = read.nextInt();
b.add(ele);
}
// Update the code below to solve this problem
int avail = 0;
int need = 0;
int count = 0;
for(int l=0;l<n;l++){
if(l==0){
avail = a.get(l);
need = b.get(l);
if(need <= avail){
count++;
}
}
else if(l > 0){
avail = a.get(l)-a.get(l-1);
if(b.get(l) < avail){
count++;
}
}
}
System.out.println(count);
}
}
}
Learning course: Java for problem solving - 2
Problem Link: CodeChef: Practical coding for everyone
Can someone point out the flaw in my code? Thanks