当前位置:网站首页>Leetcode-162- find the peak value (two points must be seen)
Leetcode-162- find the peak value (two points must be seen)
2022-07-18 09:28:00 【z754916067】
subject

Ideas
- The topic seems quite simple It is demand. O(log n) Complexity The first reaction is dichotomy
- The answer is exquisite , To learn
Code
// Dichotomy seems to be able to find Have a try
// Set boundaries
int start = 0;
int end= nums.length - 1;
while (start<end){
//middle Doing so can avoid and start or end equal
int middle = start + (end - start) / 2;
if (nums[middle] > nums[middle + 1]) {
// The peak must be bigger than its next
end = middle;
} else {
// Add 1 It must be possible to narrow the scope
start = middle + 1;
}
}
return start;
边栏推荐
- Configuration of log server
- 【MT2126】 数字游戏
- 下班前几分钟,我彻底弄懂了JSON.stringify()
- 网络信息查看及配置
- 【ARCGIS创建中国南海诸岛及九段线小图框】
- Airiot Q & A issue 4 | how to use data analysis engine?
- 成长一夏 挑战赛|跟大佬学习 / 创作,得CSDN大礼包、专属荣誉证书、纪念T恤和勋章!
- 安装CUDA失败的情况nsight visual studio edition失败
- Educational Codeforces Round 131 A - D
- Tengshi's new luxury medium and large MPV is exposed, safe and comfortable
猜你喜欢

Ubuntu 22.04 LTS 是目前最安全的版本的七大原因

华为云Stack南向开放框架,帮助生态伙伴高效入云

Opengauss cooperates with industry innovation to build a root community of open source databases

4-Redis架构设计到使用场景-Redis请求执行过程

User login and registration function with verification code

6-Redis架构设计到使用场景-持久化机制、缓存失效策略、缓存命中率

Codeforces Round #803 (Div. 2) A. XOR Mixup

AIRIOT答疑第4期|如何使用數據分析引擎?

安装CUDA失败的情况nsight visual studio edition失败

A few minutes before work, I thoroughly understood json stringify()
随机推荐
下班前几分钟,我彻底弄懂了JSON.stringify()
CSDN blog expert exclusive honor award is coming
设计稳定的微服务系统时不得不考虑的场景
答读者问(7):关于doublet
BTC与科技股相关性减弱 市场不确定性增强?53%投资者将转向另类资产
Research on Key Technologies of asset detection in Cyberspace
【MT2109】矩形
LeetCode-14-最长公共前缀
HCIP第八天笔记
Analysis on the application security and technology of electronic signature
Leetcode-62-different paths
4-Redis架构设计到使用场景-Redis请求执行过程
idea 新建项目时克隆仓库代码
Ubuntu 22.04 LTS 是目前最安全的版本的七大原因
Leetcode-14-longest public prefix
华泰证券网上开户安全吗,为什么还要身份证银行卡呢
迪赛智慧数——折(渐变堆叠图):全国居民人均可支配收入
DMS如何赋权数据库函数权限呢?
[ArcGIS creates a small picture frame of islands and nine segment lines in the South China Sea]
Build a data-based system and start a new era of oid track