Doubt in my code

why my one of the testcase is getting failed ?

Make it as
a[0]<=a[1]
and then check.

1 Like

Also this is wrong
isSorted(n-1, a+1)
instead do this
isSorted(n, a+1)

yes it passed all the test cases. Thank you

why is it wrong ?Could you please tell me

This is also wrong

if(n==0 or n==1){
        return true;
 }  

cause we will iterate from starting , wait let me give you a clear code.

ok i am waiting…

check this

Also if you want to do it like your previous code, you can do it like this also

1 Like

Ok I understand, what you want to say… :slightly_smiling_face:

Now apply it in your code and submit again.

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.