当前位置:网站首页>二分模板总结
二分模板总结
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

Wireshark basic tutorial Ethernet frame analysis.

242. Effective letter heteronyms

企鹅龙(DRBL)无盘启动+再生龙(clonezilla)网络备份与还原系统

Traversal recursion + iteration of binary tree

0x00007ffd977c04a8 (qt5sqld.dll) (in a.exe): 0xc0000005: an access violation occurred when reading position 0x0000000000000010

How to assemble a registry?

Le audio specification overview

软件测试综述之软件测试的背景、实质、软件开发的过程

mother
随机推荐
@The real difference and usage between validated and @valid
Stringing of macro parameters and connection of macro parameters in C language
Postman export import
Traversal recursion + iteration of binary tree
Scrapy ip代理无响应
BLE之ATT请求
Linkedblockingqueue of novice source code
Bash shell学习笔记(四)
面试过程中,面试官是如何考察Rust工程师的水平?
HCI interface
很多人都不清楚自己找的是Kanban软件还是看板软件
Connection between PLC and servo motor
-bash: ./build. Sh: /bin/bash^m: bad interpreter: no that file or directory
1837. Sum of digits under k-ary representation
3dunity game project practice - first person shooting game
Classified by the number of 1 in binary number
Bash shell学习笔记(三)
经典蓝牙的连接过程
easyui04
Logging learning final edition - configured different levels of log printing colors