Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Search in a rotated sorted array
//Searcch in a rotated sorted array class Solution { public: int search(vector<int>& nums, int target) { int s=0; int e=nums.size()-1; int mid; while(s<=e) { mid=(s+e)/2; if(nums[mid]==target) { return mid; } else if(nums[mid]>=nums[s]) { if(target>=nums[s] and target<=nums[mid]) { e=mid-1; } else { s=mid+1; } } else { if(target>=nums[mid] and target<=nums[e]) { s=mid+1; } else { e=mid-1; } } } return -1; } };
run
|
edit
|
history
|
help
0
ADVENTURE CODE CSCI 40
g++ -g bug
MatrixVectorConversion
test
Scemo
PointClassOpLoad
function pointer overload
Radix sort
Widget Class with dynamic memory and pointers
Изволов#8