Search a rotated sorted array
medium~25 min#arrays#binary-search
A sorted array has been rotated at some unknown pivot — [7, 9, 1, 3, 5], say. Find the index of a target value in O(log n), or report that it is absent.
The invariant to articulate: at every step, at least one half of the current range is still sorted. Say how you determine which, and what you do with that.
Solution — locked
Sign in to unlock this one
The solution opens once you explain the idea in your own words and it passes the grader — which needs an account to record. Signing in is free.
Log in