Can anyone tell what is wrong. I got other test cases. Test case 2 is giving me trouble

Your `nums`

list should have been sorted after some rotations, but I can see your list even after rotating n times will not be sorted, Please use a list `nums`

which can be sorted after some rotations.

Does our list which we give as 'nums 'should be in sorted order.

Problem statement says that input list is a rotation of a sorted list.

For example, if we have a sorted list like `[1, 3, 5, 7, 9, 12]`

. And, we have rotated this original list 3 times. Then,

after 1st rotation, the list will be` [12, 1, 3, 5, 7, 9]`

after 2nd rotation, the list will be` [9, 12, 1, 3, 5, 7]`

and after 3rd, the list will be `[7, 9, 12, 1, 3, 5, 7]`

So, the list` [7, 9, 12, 1, 3, 5, 7]`

will be our input i.e. `nums`

because when it will be back-rotated `3`

times, it will become sorted i.e. `[1, 3, 5, 7, 9, 12]`

, and the number `3`

will be our output which is basically the number of times the sorted list was rotated.

Hence, the input list should be a list such that after certain back-rotations, it becomes sorted.

Well in test case #2 we are not rotating the list. So I should be able to get the output as 0. But I cant. Can someone help me?

I can see this list is not sorted yet.

it should be like

nums = [21, 27, 32, 63, 76, 98]

also don’t repeat elements in list.

What you have written your function to calculate rotations?

This passed in my function see…

And also tried your function. I think you should Restart Notebook and Clear Outputs and Run all again it. Try it may work…

Guess I should go through my code. Thanks…

I found the error. Thanks once again.