Still sir i followed your instruction still testcases are not passing

#include
using namespace std;

int max_len(int a[],int n){

int i=0;
int M=0;

while(i+1<n){
    int len=1;
    while(i+1<n and a[i]<=a[i+1]){
        i++;
        len++;
    }
    while(i+1<n and a[i]>=a[i+1]){
        i++;
        len++;
    }
    M=max(M,len);
}
return M;

}
int main() {

int T;
cin>>T;
while(T--){
    int a[1000000];
    int n;
    cin>>n;
    
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cout<<max_len(a,n)<<endl;
}


return 0;

}

@Harshit-Kumar-2577121455897279 this is incorrect approach!
take separate arrays inc[ ] and dec[ ] which will store length of longest increasing and decreasing subarray starting at i. now answer is max(inc[i]+dec[i]-1)

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.