Wrong answer 6 test case right 3 wrong

#include
using namespace std;

int checker(int a, int b)
{
if(a>b)
{
return 0;
}
else if(a<b)
{
return 1;
}
}

int main()
{
int arr[1000];
int n;
cin>>n;

for(int i=0;i<n;i++)
{
    cin>>arr[i];
}

int store = checker(arr[0],arr[1]);

int j = 0;

if(store==0)
{
    for(;j<n-1;j++)
    {
        if(arr[j]<arr[j+1])
        {
            cout<<"false"<<endl;
            break;
        }
    }
    if(j==n-1)
    {
        cout<<"true"<<endl;
    }
}

else if(store==1)
{
    for(;j<n-1;j++)
    {
        if(arr[j]>arr[j+1])
        {
            cout<<"false"<<endl;
            break;
        }
    }
    if(j==n-1)
    {
        cout<<"true"<<endl;
    }
}

return 0;

}

your approach is wrong
firstly take a counter variable initialised to zero, run it till arr[counter] > arr[counter+1]
when this will break your counter will be at the end of the decreasing seq, increment it
now check for arr[counter] < arr[counter+1]
if counter == n-1 at the end, return true else return false

i just copy it from editorial

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.