Increasing decreasin problem

#include

using namespace std;

int main(){
int n;
cin>>n;
int *arr = new int[n];
for (int i = 0; i < n; ++i){
cin>>arr[i];
}
int i;
for(i = 0; i < n-1; i++)
{
if (arr[i] < arr[i + 1]){
break;
}
}
i++;
for (; i +1< n; ++i){
if(arr[i] > arr[i + 1]){
cout<<“false”;
return 0;
}
}
cout<<“true”;
return 0;
}

Hello @sudhanshu8917,
From next time share your code using Online Coding Blocks IDE.
The way you have shared it is introducing many runtime errors to it.

Steps:

Paste it on Online Coding Blocks IDE.
Save it there.
Share the URL generated.
Now, coming back to your problem:
You are required to keep track of following:

strictly increasing (entirely) eg. [1,2,3,4]
strictly decreasing (entirely) eg. [5,3,2,0]
First strictly decreasing than strictly increasing eg. [5,3,1,4,6]
if yes,
print true
else,
print false
strict function: which do not contain the same number at consecutive positions i.e. same values cannot occur one after other.
example: [1, 1, 2] This is not a strict function as there are two 1 at consecutive locations.

Hint: there should be no decrease in sequence if it once starts increasing i.e. first increasing then decreasing returns false. eg. [2,4,7,3,1] (not accepted)

Hope, this would help.
if you still have doubts, feel free to ask.
Give a like, if you are satisfied.

1 Like

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.