Increasing or Decreasing functions

Please tell the mistake in my code ,…

your approach is incorrect. think about a simple test case, say
2 3 6 5 7 1 array with 6 elements. try to dry run your code in this example, you will know why your approach is wrong.

this problem can be solve in a single scan of array. you need to figure out the element till which array is strictly decreasing.
for eg. 1. 4 2 3 8 9, upto element 2 array is decreasing
eg 2. 5 6 7 1 2 , array is increasing from start, so the element is 5.

once we get that element, you just need to check that the array must be in increasing order afterwards.

algorithm:
step1 loop from i=0 to n-2
break the loop when arr[i]<=arr[i+1]

step2: loop from j=i to n-2
break the loop when arr[j]>=arr[j+1]
step3: true if j == n-1
false otherwise
thanks
thanks

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.