RAINBOWA Getting WA

Can u please help me where i am worng in the code

/*
Author-> Codie_1(Akash)
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(n) for(long long i=0;i<n;i++)
#define repp(n) for(long long i=0;i<=n;i++)
#define w(t) int t; cin>>t; while(t–)
#define endl ‘\n’
#define pb push_back
#define mk make_pair
#define vi vector v
#define vl vector v;
typedef long long ll;

/The answer is just sumW - N * minW, where sumW is the sum of all W[i] and minW is the minimum over all W[i]./
int main()
{
// fast
w(t)
{
int n;
cin>>n;
int arr[n];
rep(n)
{
cin>>arr[i];
}
int i=0,j=n-1;
bool flag=true;
while(i<=j)
{
if(arr[i]!=arr[j])
{
flag=false;
break;
}
if(i==j)
{
if(arr[i]!=arr[i-1]+1 || arr[i]==arr[i-1])
flag=false;
}
i++;
j–;
}
if(flag)
cout<<“yes\n”;
else
cout<<“no\n”;
}

return 0;

}

Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile! :slight_smile:

https://www.codechef.com/viewsolution/33527258 please check

1 Like

Thanks :slight_smile:

1 Like