Back to DSA sheet

Search in Rotated Sorted Array

MediumBinary Search
Open on LeetCodeAmazonGoogleMetaMicrosoft

A sorted array of distinct values was rotated at an unknown pivot. Return the index of a target value, or -1 if it is absent, in O(log n).

Constraints
  • 1 <= nums.length <= 5000
  • All values are distinct
  • -10^4 <= target <= 10^4
Sheets
Blind 75Grind 75Love Babbar 450NeetCode 150NeetCode 250Striver A2Z
search-in-rotated-sorted-array.cpp
Loading editor
Custom input (stdin)
Output

Run your code to see its output.