Bonus Question 1

Looking for hint to pass test case #6 (an empty list) and #7 (A list containing just one element).

Your First condition is:

if mid > 0:

Remove this and make the indentation correct…
I don’t know how are you passing the case where a list is not rotated at all and has more than 1 element because your code should return -1 for those cases also…

In the condition :

if nums[mid] > 0 and nums[mid] < nums[mid-1]:

Add to check if mid is 0 like this:

if nums[mid] > 0 and nums[mid] < nums[mid-1] or mid==0:

Now for the empty case, you should change your expected return value to -1 because how can you rotate a list which has no element so the answer should be -1 for such

Hope it helps…
Ask if any doubt…

1 Like

Thank you for the response. This is very helpful. I updated the condition and changed the expected return value to -1 for the empty case. All tests passed.

1 Like