Search in Rotated Sorted Array
Given the array nums after the possible rotation and an integer target, return the index of target if it is in nums, or -1 if it is not in nums.

30:00

Search in Rotated Sorted Array
medium
Topics
Companies

Given the array nums after the possible rotation and an integer target, return the index of target if it is in nums, or -1 if it is not in nums.

Example 1:
Input: {"nums":[4,5,6,7,0,1,2],"target":0}
Output: 4
Constraints:
  • 1nums.length50001 \leq \text{nums.length} \leq 5000

  • 104nums[i]104-10^4 \leq \text{nums}[i] \leq 10^4

  • All values of nums are unique.

  • nums is an ascending array that is possibly rotated.

  • 104target104-10^4 \leq \text{target} \leq 10^4

Input
arr ={"nums":[4,5,6,7,0,1,2],"target":0}
Target: 0

4

L

5

6

7

0

1

2

R
Variables
No variables to display
DepthFunction Call
Stack empty
0/13