当前位置:网站首页>Searching for single element in dichotomy
Searching for single element in dichotomy
2022-06-30 14:40:00 【Douglas_ LT】
A daily topic ing, Today is a day medium topic 540. Single Element in a Sorted Array
class Solution {
public:
int singleNonDuplicate(vector<int>& nums) {
int l=0,r=nums.size()-1;
while(l<r){
int mid=(l+r)/2;
if(mid%2==1){
mid--;
}
if(nums[mid]==nums[mid+1]){
l=mid+2;
}
else{
r=mid;
}
}
return nums[r];
}
};
边栏推荐
- ot initialized – call ‘refresh’ before invoking lifecycle methods via the context: Root WebApplicati
- Summary of use of laravel DCAT admin
- Three uses of golang underscores
- Error $(...) size is not a function
- Go language func function
- go channel && select
- Detailed explanation of the first three passes of upload Labs
- [geek challenge 2019] PHP problem solving record
- Solution cannot use a scalar value as an array
- Complete TCP forwarding server (kernel linked list + mutex)
猜你喜欢
Getting started with shell Basics
Lihongyi machine learning 2020 homework summary
[buuctf] [actf2020 freshman competition]include
Detailed explanation of settimeout() and setinterval()
【BUUCTF】 EasySql
go channel && select
XSS challenge (6-10) more detailed answers
Why does the folder appear open in another program
Laravel upload error
V3 03_ Getting started
随机推荐
The JSON data returned from the control layer to JS has a "\" translator. How to remove it
Using docker to manage MySQL services under Windows
Getting started with shell Basics
Wechat applet realizes map navigation + door-to-door recycling
JS to realize simple lottery function
2021 geek challenge Web
Invalid argument during startup: Failed to open the . conf file: redis-window
Lost connection to the flow server (0 retries remaining): |Out of retries, exiting! Error reporting solution (flow)
Larave8 JWT API expiration custom error return
Use PHP to delete the specified text content in the file
Summary of use of laravel DCAT admin
Mysql database foundation: stored procedures and functions
Is it troublesome for CITIC futures to open an account? Is it safe? How much is the handling charge for opening an account for futures? Can you offer a discount
V3_ Chrome extended Chinese translation document V3 directory
Pit used by go language array type
Experiment 2: stack
PHP generate images into Base64
JS delete the objects in the array and specify to delete the objects
For loop and promise to solve the problem of concurrent callback
V3 03_ Getting started