Skip to content

Commit

Permalink
Time: 3 ms (64.95%), Space: 11.3 MB (9.38%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
Dipendra-Raghav committed Sep 30, 2023
1 parent fc0b807 commit 3661b06
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class Solution {
public:
int solve(vector<int> &nums,int target)
{
int s=0;
int e=nums.size()-1;
while(s<=e)
{

int mid=(s+e)/2;
if(nums[mid]==target)return mid;
else if(nums[mid]>=nums[s])
{
if(target>=nums[s] && target<nums[mid])
e=mid-1;
else
s=mid+1;
}
else
{
cout<<"hi"<<endl;
if(target>=nums[mid] && target<=nums[e])
s=mid+1;
else
e=mid-1;
}
}
return -1;
}
int search(vector<int>& nums, int target) {
return solve(nums,target);

}
};

0 comments on commit 3661b06

Please sign in to comment.