Why is it that my rainbow array code is giving wrong after submission?

//heres my code
#include
using namespace std;
int Check(int n,int a[])
{
int count=0;
for(int i=0;i<n/2;i++)
{
if((a[i]==a[n-i-1])&&(a[n/2]==7)&&(a[i]-a[i+1]<=1))
{
count++;
}
else return -1;
}
}
int main()
{
int a[93],N;
cin>>N;
for(int i=0;i<N;i++)
cin>>a[i];
int b = Check(N,a);
if(b==-1)
cout<<“no”;
else
cout<<“yes”;
return 0;
}

You should initialize your array with size N, instead of 93. I’m not sure why did you initialize your array of size 93. Anyway, your logic is still not complete, check out this help or you can check out the editorial

#include

using namespace std;

int Check(int n,int a[])

{

int count=0;

for(int i=0;i<n/2;i++)

{

if((a[i]==a[n-i-1])&&(a[n/2]==7)&&(a[i]-a[i+1]<=1))

{

count++;

}

else return -1;

}

}

int main()

{

int N;

cin>>N;

int a[N];

for(int i=0;i<N;i++)

cin>>a[i];

int b = Check(N,a);

if(b==-1)

cout<<“no”;

else

cout<<“yes”;

return 0;

}

//i wrote my code again but it still gives wrong answer
//heres my code
#include
using namespace std;
int main()
{
bool flag=false;
int N,t,j;
cin>>t;
while(t>0)
{
cin>>N;
int a[N];
for(j=0;j<N;j++)
{
cin>>a[j];
}
for(int k=0;k<N/2;k++)
{
if((a[k]-a[k+1]<1)&&(a[N/2]==7)&&(a[k]==a[N-k-1]))
{
flag=true;
}
else
{
flag=false;
break;
}
}
t–;
}
if(flag)
cout<<“yes”;
else
cout<<“no”;
return 0;
}