Can you please check what’s wrong with my code as I’m getting my test case wrong.
// code
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int row = sc.nextInt();
while(row!=0) {
int n = sc.nextInt();
int[] arr = new int[n];
input(arr);
System.out.println(bitonic(arr,n));
row--;
}
}
public static void input(int[] arr) {
for(int i=0;i<arr.length;i++) {
arr[i]=sc.nextInt();
}
}
public static int bitonic(int[] arr,int n) {
int[] inc = new int[n];
int[] dec = new int[n];
int i,max;
inc[0] = 1;
dec[n-1] = 1;
for(i=1;i<n;i++) {
if(arr[i]>=arr[i-1]) {
inc[i]=inc[i-1]+1;
}else {
inc[i]=1;
}
}
for(i=n-2;i>=0;i--) {
if(arr[i]>=arr[i+1]) {
dec[i]=dec[i+1]+1;
}else {
dec[i]=1;
}
}
max = inc[0]+dec[0]-1;
for(i=1;i<n;i++) {
if(inc[i]+dec[i]-1>max) {
max = inc[i]+dec[i]-1;
}
}
return max;
}
}