Here is my code. I cannot seem to find an error in this. Please rectify and also tell a test case for which it fails. TIA
#include
#include<bits/stdc++.h>
using namespace std;
int main() {
int t,n;
cin >> t;
while(t–){
cin >> n;
int a[n];
for(int i = 0 ; i < n ; i++){
cin >> a[i];
}
int len = 1, i = 1,maxlen=0;
while( i < n ){
len = 1;
while(a[i-1] < a[i] && i < n){
len++;
i++;
}
while(a[i-1] > a[i] && i < n){
len++;
i++;
}
maxlen = max(len,maxlen);
}
cout << maxlen << endl;
}
return 0;
}