Problem
You get an array nums of unique integers and an integer target. At first, the items were in ascending order. Then the array possibly had some rotations.
One rotation moves the last item of the array to the front. For example, two rotations change [1, 2, 3, 4] into [3, 4, 1, 2]. You do not know the number of rotations.
Return the index of target in nums, or -1 if target is not in nums. Your solution must run in O(log n) time.
Example 1
- Input:
- nums = [14,19,23,2,5,9], target = 5
- Output:
- 4
- Explanation:
- The value 5 is at index 4.
Example 2
- Input:
- nums = [14,19,23,2,5,9], target = 20
- Output:
- -1
- Explanation:
- The value 20 is not in
nums.
Example 3
- Input:
- nums = [4], target = 4
- Output:
- 0
Constraints
- 1 <= nums.length <= 5000
- -10^4 <= nums[i] <= 10^4
- All the values in nums are unique.
- nums is an ascending array that possibly had some rotations.
- -10^4 <= target <= 10^4
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Find First and Last Position of Element in Sorted Array
Coding · Array · Binary Search
- Binary Search
Coding · Array · Binary Search
- Binary Searchable Numbers in an Unsorted Array
Coding · Array · Binary Search · Monotonic Stack
- Median of Two Sorted Arrays
Coding · Array · Binary Search · Divide and Conquer
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 3 records
Expedia
Leetcode 33. Search in Rotated Sorted Array
Reported Jun 24, 2026 · 2 source reports
MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceLinkedIn
Leetcode 33. Search in Rotated Sorted Array
Reported Sep 7, 2026 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceMeta
Leetcode 33. Search in Rotated Sorted Array
Reported Jul 15, 2025 · 2 source reports
MANAGER, SENIOR
Source snapshot: Nov 12, 2026
View source
LeetCode company tags · 6 records
Amazon
Search in Rotated Sorted Array