At any midpoint, one half of the array is always sorted. Identify which half is sorted, then check if the target falls within that sorted range.
Compare nums[left] with nums[mid]. If nums[left] <= nums[mid], the left half is sorted. Otherwise, the right half is sorted.
Once you know which half is sorted, check if target lies in that range. If yes, search there. If no, search the other half.
With nums = [4, 5, 6, 7, 0, 1, 2] and target = 0: mid is index 3 (value 7). Left half [4, 5, 6, 7] is sorted. Is 0 in [4, 7]? No. Search right half. Continue until found.