hello all , kindly help me through this, I am unable to know that in my solution where is the mistake so kindly help me please
COVID19 - Editorial
problem link : CodeChef: Practical coding for everyone
my solution:
/* package codechef; // don’t place package name! */
import java.util.;
import java.lang.;
import java.io.*;
/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
while (t-- > 0) {
int n =scan.nextInt();
long[] a = new long[n];
for (int i=0;i<n;i++)
a[i] = scan.nextLong();
ArrayList<Long> x = new ArrayList<>();
long count = 1;
for(int i=0;i<n-1;i++){
int j = i;
if((a[j+1]-a[j])<=2&&(a[j+1]-a[j])>=0){
count++;
}
else{
x.add(count);
count=1;
}
}
if(count>1)
x.add(count);
Collections.sort(x);
System.out.print(x.get(0)+" ");
System.out.print(x.get(x.size()-1));
System.out.println();
}
}
}