SPLIT THE SEQUENCE INCREASING DECREASING

WHY MY CODE IS FAILING THE 4 TEST CASES EVEN IF I HAVE CROSS CHECKED WITH THE TEST CASES
MY CODE IS PRODUCING SAME OUTPUT AS IT IS IN TEST CASE OUTPUT,BUT STILL ITS REJECTING.

#include <bits/stdc++.h>
using namespace std;
int freq(int *a,int n,int length){
int c=0;
for(int i=0;i<length;i++){
if(a[i]==n)
c++;
}
return c;
}
bool in(vector &v,int n){
for(auto i:v){
if(i==n)
return true;
}
return false;
}
void display(vector &v){
cout<<endl;
for(auto i:v)
cout<<i<<" ";
cout<<endl;
}
int main(){

int n,i;
bool b=1;
cin>>n;
int s[n];
for(i=0;i<n;i++)
    cin>>s[i];
for(int i=0;i<n;i++){
    if(freq(s,s[i],n)>2 || n<4)
    {
        cout<<"false";
        b=0;
        break;
    }
   
}
if(b){

cout<<"true";
}
return 0;

}

Save your code on ide.codingblocks.com and then share its link.

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.