What is wrong with this approach? It is giving me the right output for the sample test cases in the questions, but while submitting no test cases are being passed !
// Bitonic Subarray
#include <bits/stdc++.h>
using namespace std;
int bitonic(int a[], int n){
int c=0;
if(n==0 || n==1 || n==2)
return n;
for(int i=0;i<n-2;i++){
if(a[i]>a[i+1] && a[i+1]<a[i+2]){
c=0;
continue;
}
else
c++;
}
if(n>3)
return c+2;
else
return c;
}
int main() {
int t; cin>>t;
while(t–){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
int ans = bitonic(a,n);
cout<<ans<<endl;
}
}
