Search for a target in a rotated sorted array. Return its index or -1 if not found. You must achieve O(log n).
The trick: at any mid point, one half is always sorted. Check if target falls in the sorted half. If yes, search there. Otherwise, search the other half.
nums[left] <= nums[mid]: left half is sorted[nums[left], nums[mid]]search([4,5,6,7,0,1,2], 0)
4
search([4,5,6,7,0,1,2], 3)
-1