mediumBinary Search Pattern

Search in Rotated Sorted Array

There is an integer array `nums` sorted in ascending order (with distinct values) that has been rotated at some pivot. Given the array and a target value, return the index of target if found, or -1 otherwise. You must write an algorithm with O(log n) runtime complexity.

Examples

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

Hints (0/2)

Try to solve it first! Click "Reveal Next Hint" if you get stuck.

Your Code:
Results:
Output

Click "Run" to execute your code