What is the problem in this code?


this is the link to my version of the solution to this problem.
it is not able to pass 3 test cases and i am not able to find any problem in my code

Hi alankrit

  1. You have not initialized xp
  2. Assuming that xp represents previous value in array, you are accepting array elements if they are less than or greater than previous element but not equal to. This logic is incorrect.
    Like in example array : 4 5 6 5 4 , answer = false, the sequence should be first decreasing and then increasing. but your ans = true.

Try thinking of the logic

Hope it helps
GIve a like if you’re satisfied :slight_smile:

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.