-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Day 18 q2: Search in Rotated Sorted Array #409
Comments
Pls assign this issue to me @sumiranverma @karishma-2020 |
Please assign this to me @bh-g @kratika-Jangid |
please assign this question to me :) @bh-g |
Please assign it to me @bh-g @kratika-Jangid @karishma-2020 |
@bh-g please assign this issue too me :) |
please assign this issue to me.... |
Please assign this to me @bh-g @kratika-Jangid |
@bh-g please review my PR |
Please Merge my PR.. |
Solved Day 18 q2: Search in Rotated Sorted Array #409
@bh-g please assign this issue to me, I want to use another approach to solve this question :) |
@bh-g @kratika-Jangid @karishma-2020 please assign this issue to me. I have a better approach to solve. |
There is an integer array
nums
sorted in ascending order (with distinct values).Prior to being passed to your function,
nums
is possibly rotated at an unknown pivot indexk
(1 <= k < nums.length
) such that the resulting array is[nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]]
(0-indexed).For example,
[0,1,2,4,5,6,7]
might be rotated at pivot index3
and become[4,5,6,7,0,1,2]
.Given the array
nums
after the possible rotation and an integertarget
, return the index oftarget
if it is innums
,or -1 if it is not in
nums
.You must write an algorithm with
O(log n)
runtime complexity.Example 1:
Input:
nums
= [4,5,6,7,0,1,2],target
= 0Output: 4
Example 2:
Input:
nums
= [4,5,6,7,0,1,2],target
= 3Output: -1
Example 3:
Input:
nums
= [1],target
= 0Output: -1
Constraints:
nums
.length <= 5000nums
is an ascending array that is possibly rotated.target
<= 10^4question link
: https://leetcode.com/problems/search-in-rotated-sorted-array/The text was updated successfully, but these errors were encountered: