Your question is Binary Search on Rotated Array. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Grab's mobile systems may receive sorted identifier data that has been rotated when batches are partitioned or refreshed. Given a rotated sorted array of distinct integers, return the index of a target value using binary search.
The array was originally sorted in strictly increasing order, then rotated at an unknown position. Return -1 if the target is not present.
Implement search(nums, target).
nums, a list of distinct integers, and target, an integer.target in nums, or -1 when it is absent.def search(nums, target):