Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Alternative Solution

Pete Stenger

Oct 26, 2024

    lo = 0     hi = len(arr) - 1     while lo <= hi:       mid = (lo + hi) // 2       if mid > 0 and arr[mid-1] > arr[mid]:         return mid       if arr[0] < arr[mid]:         lo = mid + 1       else:         hi = mid - 1         return len(arr) - 1 - mid

1

0

Comments
Comments

On this page