Whats the error in this code

Hi @Namanjain123
The approach that you are using is failing for many cases like :
5
1
2
6
4
5
here the output should be false but your code is printing true. You need to change the approach to this question. Best optimal approach is that you need not to take array, one can also perform the question without using array. As every time we just check two consecutive numbers to tell whether the seqeunce is increasing or decreasing, so why should we store all of the numbers.

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.