Increasing Decreasing Sequence Problem Test Cases

Hi, I am unable to solve for all test case, Please help me out https://ide.codingblocks.com/s/80305

Check if your code is giving “True” as output for the below three conditions:

  1. Frst decreasing then increasing.
  2. Completely decreasing.
  3. Completely increasing.

If you it is still face problem… Then let me know

hey,
In the same problem 2nd test case is showing wrong answer. i would be really glad if you could help.

for(j=0;j<temp;j++){
if(a[j]<a[j+1]){
cout << “false”;
break;
}
}

i was wondering if this would ever execute? think.

and run your code for: 5 5 4 3 2 1
it will help you to figure out your mistake.
what should be the value of temp before third loop and what is it actually? think.

hopefully, this would help.

Hi Sir, have checked the code for these three conditions it return true for all these test cases.

“First decreasing then increasing.”
“Completely decreasing.”
“Completely increasing.”

now, check for this

5
5
4 //focus here
4 //
3
4

Hint: a strictly increasing or strictly decreasing function does not contain equal values.

solve this issue, and your code will pass all the test cases.

the code return false for the 5 5 4 4 3 4

unable to figure out where the actual issue lies, Please help

@Shobhit-Sharma-1473370192798371 Check, again.
Your code is returning true for 5 5 4 4 3 4
I just executed it on this input and it is returning true

Sir, this is the url of my code “https://ide.codingblocks.com/s/80305” and this is the response that I am getting this reponse, I guess you might be referring to wrong url.

I hope this is not frustrating you that instead of sharing the correct code, I am just pointing out ur mistakes again and again.
But trust me, these learnings will help you in future.
Try to run it for:
5
1
2
3
2
1
The answer should be false

Suggestion:

  1. Next time, Run your code for all possible inputs.
  2. Understand the question and Try to think of all possible kind of inputs for your problem.

For this problem:

  1. decreasing then increasing : true
  2. Decreasing : true
  3. Increasing : true
  4. Single input (example: 1 5) : true
  5. Increasing then decreasing : false
  6. Same values at consecutive places : false

Feel free to ask again