当前位置:网站首页>二分模板总结
二分模板总结
2022-07-26 10:56:00 【哈拉泽空】
case 1: 要找某个值,返回有没有找到true or false
l=0, r=nums.size()-1
while(l<=r)
l=mid+1
r=mid-1
(不用返回下表,所以返回true or false即可)case 2: 要找某个值,返回下标
l=0, r=nums.size()-1
while(l<r)
l=mid+1
r=mid
return lcase 3: 要找某个值,返回下标2(l<=r的话,一定不能写l=mid或者r=mid,这样可能会死循环)
l=0, r=nums.size()-1
while(l<=r){
return mid;
l=mid+1;
r=mid-1;
}边栏推荐
- Connection between PLC and servo motor
- @NotBlank、@NotNull 、@NotEmpty 区别和使用
- MySQL死锁分析
- MySQL quicklearn-2021-09-01
- Novice source code hashtable
- 242. Effective letter heteronyms
- Interview knowledge points
- Classic Bluetooth connection process
- BigDecimal's addition, subtraction, multiplication and division, size comparison, rounding up and down, and BigDecimal's set accumulation, judge whether BigDecimal has decimal
- mother
猜你喜欢

Le audio specification overview

Linkedblockingqueue of novice source code

Capture ZABBIX performance monitoring chart with selenium

使用Selenium抓取zabbix性能监控图

232. Implement queue with stack

Why do I need automated testing? Software testers take you to evaluate different software testing tools

349. Intersection of two arrays

easyui03

并发三大性质

easyui04
随机推荐
Scrapy ip代理无响应
ISO 639:1988 : Code for the representation of names of languages
pytest 前后置方法
软件测试综述之软件测试的背景、实质、软件开发的过程
MultipartFil转为File
ESXi6.5补丁更新
Sword finger offer (52): regularization expression
Simple use of MFC multithreading
Minesweeping Pro version 2021-08-19
Esxi6.5 patch update
看源码之LinkedList
104. Maximum depth of binary tree
SparseArray of the source code for novices
ThreadPoolExecutor是怎样执行任务的
Stringing of macro parameters and connection of macro parameters in C language
Pytest case execution sequence
easyui01
LinkedList of source code
Fragment 懒加载
Kali view IP address