I am going wrong with one test case

can u suggest best approach for it

@kadaparaghavendra1
remember that only single element in array is valid here and only decreasing or only increasing is also valid.
your code is giving wrong output for n=1 and for reverse sorted array.

1 Like

if you want best approach for this problem look at this code (https://ide.codingblocks.com/s/202624)

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.