当前位置:网站首页>Binary rotation array (1)
Binary rotation array (1)
2022-06-30 14:37:00 【Douglas_ LT】
A daily topic ing, Today is a day medium topic 81. Search in Rotated Sorted Array II
class Solution {
public:
bool search(vector<int>& nums, int target) {
int len=nums.size();
if(len==0){
return false;
}
int l=0,r=len-1;
while(l<=r){
int mid=(l+r)/2;
if(target==nums[mid]){
return true;
}
if(nums[l]==nums[mid]){
l++;
continue;
}
if(nums[l]<nums[mid]){
if(target<nums[mid]&&target>=nums[l]){
r=mid-1;
}
else{
l=mid+1;
}
}
else{
if(target>nums[mid]&&target<=nums[r]){
l=mid+1;
}
else{
r=mid-1;
}
}
}
return false;
}
};
边栏推荐
- Initial attack and defense world Misc
- V3_ Chrome extended Chinese translation document V3 directory
- @Component use cases
- I love network security for new recruitment assessment
- Error on datetime when importing SQL file from MySQL
- DiceCTF - knock-knock
- Invalid argument during startup: Failed to open the . conf file: redis-window
- "Persistent diseases" that cannot be solved in IM application development
- DB2 SQL Error: SQLCODE=-206, SQLSTATE=42703
- @component使用案例
猜你喜欢
XSS challenge (6-10) more detailed answers
1 figure to explain the difference and connection between nodejs and JS
Using docker to manage MySQL services under Windows
val_ Loss decreases first and then increases or does not decrease but only increases
Clear the route cache in Vue
Initial attack and defense world Misc
Crypto questions
Fastcgi CGI shallow understanding
DiceCTF - knock-knock
Shangpinhui knowledge points of large e-commerce projects
随机推荐
Project management - common English vocabulary I
Notepad regular delete the line of the keyword
Go common lock mutex and rwmutex
Notes on reverse learning in the first week of winter vacation
Attack and defense world web questions
JS to realize simple lottery function
Basic learning notes of C language
August 24, 2021 deque queue and stack
Effect of shadow around the block after mouse over
NoViableAltException([email protected][])
The first three passes of sqli Labs
Shell programming overview
[extensive reading of papers] multimodal joint attribute prediction and value extraction for e-commerce product
Data recovery software easyrecovery15 Download
LIS error: this configuration section cannot be used in this path
ctfshow nodejs
2021-05-12
C language & the difference between the address pointed to and the address pointed to by the pointer
On simple code crawling Youdao translation_ 0's problem (to be solved)
About the problems encountered when using the timer class to stop with a button (why does the QPushButton (for the first time) need to be clicked twice to respond?)