My issue
why am i getting a tle in last and 2nd last test case?
My code
int N=sc.nextInt();
long A[]=new long[N];
for(int i=0;i<N;i++)
A[i]=sc.nextLong();
ArrayList<Long>ds =new ArrayList<>();
int max=1;
int c=1;
ds.add(A[0]);
for(int i=1;i<N;i++){
if(ds.indexOf(A[i])>=0){
int cc=ds.indexOf(A[i]);
max=Math.max(c,max);
c=ds.size()-1;
ds.remove(cc);
}
else{
ds.add(A[i]);
c+=1;
}
}
max=Math.max(max,c);
System.out.println(max);
}
Problem Link: CARDSWIPE Problem - CodeChef