当前位置:网站首页>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;
}
};
边栏推荐
- On simple code crawling Youdao translation_ 0's problem (to be solved)
- Small exercise of process and signal
- @Role of ResponseBody
- Upgrade composer self update
- Laravel RBAC laravel permission use
- PHP conditional operator
- Laravel8 custom log directory, rename
- Error on datetime when importing SQL file from MySQL
- JS time conversion standard format, timestamp conversion standard format
- August 24, 2021 deque queue and stack
猜你喜欢

@PathVariable
![[buuctf] [actf2020 freshman competition]exec1](/img/af/22051a5feb3c1f6d7201a483bde127.jpg)
[buuctf] [actf2020 freshman competition]exec1

Why does the folder appear open in another program

Component communication mode

Notes on reverse learning in the first week of winter vacation

LIS error: this configuration section cannot be used in this path
![[buuctf] [actf2020 freshman competition]include](/img/42/50439290177fdea5f431e315cac1a1.jpg)
[buuctf] [actf2020 freshman competition]include

Thinkphp5 log file contains trick

go time. after

DefCamp Capture the Flag (D-CTF) 2021-22 web
随机推荐
Calculates the length of the last word in a string, separated by spaces
MV3 04_ Introducing Manifest V3
Use PHP to delete the specified text content in the file
go channel && select
【BUUCTF】 Have Fun
Project management - common English vocabulary I
JS array sorting method summary
Greedy interval problem (5)
Logiciel de récupération de données easyrecovery15 téléchargement
Realize a simple LAN communication (similar to feiqiu)
XSS challenge (6-10) more detailed answers
NoViableAltException([email protected][])
Wuenda 2022 machine learning special course evaluation is coming!
Uniapp upload image method
"Persistent diseases" that cannot be solved in IM application development
2021-07-14 mybaitsplus
V3 02——What‘s new in Chrome extensions
DB2 SQL Error: SQLCODE=-206, SQLSTATE=42703
The difference between settimeout() and setinterval()
数据恢复软件EasyRecovery15下载