Can you please explain why it is showing wrong answer?

#include
using namespace std;

int helper(int arr[],int N){
if(N<=2) return N;
int ans=0;
for(int i=0;i<N-1;i++){

	if(arr[i+1]>=arr[i]){
		int j=i;
		while(j<N-1 && arr[j+1]>=arr[j]){
			j++;
		}
		while(j<N-1 && arr[j+1]<=arr[j] ){
			j++;
		}
		if(j-i+1>ans) ans=j-i+1;
		//cout<<j<<" "<<i<<endl;
		i=j-1;
	}else{
		int j=i;
		while(j<N-1 && arr[j+1]<=arr[j] ){
			j++;
		}
		
		if(j-i+1>ans) ans=j-i+1;
		//cout<<i<<" "<<j<<endl;
		i=j-1;

	}
}
return ans;

}

int main() {
int t;
cin>>t;
while(t–){
int N;
cin>>N;
int arr[N];
for(int i=0;i<N;i++) cin>>arr[i];
cout<<helper(arr,N)<<endl;
}
return 0;
}

Hey @f2016911 please share code in Coding Blocks Ide.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.