Medium · Binary search
Search in Rotated Sorted Array
You are given a sorted list of distinct integers that has been rotated: some front part was moved to the back. You are also given a number, target. Return its position, or -1 if it is not there.
- Every number appears once.
- The list may not be rotated at all.
- Aim for O(log n): do not scan the whole list.
nums = [4, 5, 6, 7, 0, 1, 2] target = 0 → 4Record your take