Search a rotated sorted array
Return the index of target in a rotated strictly increasing integer list, or -1 if absent. Values are distinct.
items = [4, 5, 6, 0, 1, 2]
left, mid = 0, 2
print(items[left] <= items[mid]) # sorted halfReason about the state
At least one half around the midpoint is sorted. Check whether target lies in that half before discarding the other, retaining logarithmic search time. Before writing code, identify what each variable means after one iteration. Walk through the example and explain why the next transition preserves that meaning. Then check the smallest permitted input and a case with repeated values. A correct answer follows the contract for every input, including the boundary cases in the checks. Keep any input mutation within the stated rules; return a fresh result when the task asks for one.
Your task
Return the index of target in a rotated strictly increasing integer list, or -1 if absent. Values are distinct.
The explanation opens here once every check passes.