Skip to content
C

Search in Rotated Sorted Array

Mediumjavapythonccppjavascript

A sorted array of distinct values has been rotated at an unknown pivot. Find the index of a given target using an efficient search.

Input Format

The first line contains two integers N and target. The second line contains N space-separated distinct integers — a sorted array that has been rotated.

Output Format

Print the index of target, or -1 if it is absent.

Input (stdin)

Output

Run your code to see output here...