Has anyone been able to solve the second bonus question? I keep failing on the sample test input. I keep getting stuck and don’t know what to do. Please help me, I’ve added my approach below

extended_tests.append({

‘input’: {

‘nums’: [5, 6, 6, 9, 9, 9, 0, 0, 2, 3, 3, 3, 3, 4, 4]

},

‘output’: 6

})

Your `Expected Output: 6`

is wrong,

According to your nums list, your `Expected Output`

should be `'0'`

.

This is what your `Actual Output`

is, as your code seems to be working fine.

Thank you very much Utkarsh. Does that mean the list [5, 6, 6, 9, 9, 9, 0, 0, 2, 3, 3, 3, 3, 4, 4], need wasn’t rotated at all. Because I was thinking that the numbers 5, 6, 6, 9, 9, 9 should be that the end of the array.

Oh, wait sorry, I misread the question.

The rotation is happening before element `'0'`

which is at index `'6'`

. So yes, the `'Expected Output'`

should be `'6'`

.

I confused it with the element `'6'`

in the list.

I think the problem in your code is with the first `if`

statement.

```
if (nums[mid] == nums[mid-1]):
return 'left'
```

Because for `nums: [5, 6, 6, 9, 9, 9, 0, 0, 2, 3, 3, 3, 3, 4, 4]`

,

In first iteration,

`lo: 0 => nums[lo] : 5`

`hi: 14 => nums[hi] : 4`

`mid: 7 => nums[mid] : 0`

Now it will check for your 1st `if`

statement,

`if (nums[mid] == nums[mid-1]):`

which would be true as, `nums[mid]= 0 =nums[mid-1]`

Now `hi`

will become `mid-1 = 6`

and `mid = 3 => nums[mid] =9`

This time the first `if`

statement would fail.(why? try yourself)

This would also fail the second/main `if`

statement,

```
if(mid>0 and (nums[mid] < nums[mid-1])):
return 'found'
```

Now your `lo = 4`

and `mid = 5 => nums[mid] = 9`

Again, it will pass the first `if`

statement this time and `hi`

would become `mid -1`

i.e. `hi=4`

, which will take our `Expected Output:6`

out of the list and wouldn’t even be checked.

Sorry, for the long answer but in short, I think removing the first `if`

statement should work fine.

Wow. Thank you so much, that was super helpful