当前位置:网站首页>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];
}
};
边栏推荐
- Why does the folder appear open in another program
- 从控制层返回到js的json数据带“\”转译符,怎么去掉
- val_ Loss decreases first and then increases or does not decrease but only increases
- PHP common authentication / third-party methods
- 【BUUCTF】 Have Fun
- Mutex lock, read / write lock, spin lock, pessimistic lock, and optimistic lock
- 【BUUCTF】 EasySql
- Go language for loop multivariable use
- [buuctf] [actf2020 freshman competition]include
- V3_ Chrome extended Chinese translation document V3 directory
猜你喜欢

go time. after

Go language mutex lock

Error $(...) size is not a function

Shangpinhui knowledge points of large e-commerce projects
![【BUUCTF】[GXYCTF2019]Ping Ping Ping1](/img/dc/4d87dfb0c2fa9cd75b54e092fd3971.jpg)
【BUUCTF】[GXYCTF2019]Ping Ping Ping1

Clear the route cache in Vue

Laravel upload error

@PathVariable

Upgrade centos7 mysql5.5 to mysql5.7 non RPM in the form of tar package

JS to realize simple lottery function
随机推荐
Shell programming overview
KnightCTF WEB
C language & the difference between the address pointed to and the address pointed to by the pointer
Zend studio how to import an existing project
Detailed explanation of settimeout() and setinterval()
go channel && select
PHP 2D array change key name
【BUUCTF】 Have Fun
ot initialized – call ‘refresh’ before invoking lifecycle methods via the context: Root WebApplicati
LIS error: this configuration section cannot be used in this path
Att & CK red team evaluation field (I)
Effect of shadow around the block after mouse over
PHP excel export function encapsulation (based on phpexcel class)
Getting started with shell Basics
Summary of use of laravel DCAT admin
Wechat applet realizes map navigation + door-to-door recycling
Geoffreyhinton: my 50 years of in-depth study and Research on mental skills
2021-07-15Caused by: org. quartz. ObjectAlreadyExistsException: Unable to store Job : ‘DEFAULT. TASK_ 1‘
PHP common authentication / third-party methods
Mutex lock, read / write lock, spin lock, pessimistic lock, and optimistic lock