#C11087. Search in Rotated Sorted Array
Search in Rotated Sorted Array
Search in Rotated Sorted Array
You are given a rotated sorted array \(A\) of distinct integers and a target value \(T\). A rotated sorted array is an array that has been sorted in increasing order and then rotated at some pivot. Your task is to find the index of the target value in the array using an algorithm with O(log n) complexity. If the target is not present in the array, output \(-1\).
Example 1:
Input: A = [4, 5, 6, 7, 0, 1, 2], T = 0 Output: 4
Example 2:
Input: A = [4, 5, 6, 7, 0, 1, 2], T = 3 Output: -1
Note: The array is guaranteed to have no duplicate elements.
inputFormat
The input consists of two lines. The first line contains the elements of the rotated sorted array separated by spaces. The second line contains a single integer, the target value \(T\).
outputFormat
Output a single integer which is the index of the target value in the array. If the target does not exist in the array, output \(-1\).
## sample4 5 6 7 0 1 2
0
4