CustomerInsights.AI stores distinct customer engagement scores in ascending order, but a synchronization boundary may rotate the array. Given the rotated array and a target score, return the target's index or -1 if it is absent.
You must solve the problem with a modified binary search. The array contains distinct values, so at every iteration at least one half remains sorted.
Implement search_rotated(nums, target).
nums, a list of distinct integers formed by rotating an ascending list, and target, an integer.target in nums, or -1 when it does not occur.def search_rotated(nums, target):