Coding Challenge

Search in Rotated Sorted Array

Medium
arraybinary-search

Search a target in a rotated sorted array.

Given a rotated sorted array with unique values and a target, return the index of the target or -1 if it does not exist.

Examples

Input: nums = [4,5,6,7,0,1,2], target = 0

Output: 4

Constraints

  • 1 <= nums.length
  • All values are unique

Preparing your coding workspace...