当前位置:网站首页>leetcode:154. 寻找旋转排序数组中的最小值 II【关于旋转排序数组的中后定位二分法】
leetcode:154. 寻找旋转排序数组中的最小值 II【关于旋转排序数组的中后定位二分法】
2022-07-25 15:44:00 【白速龙王的回眸】

分析
看中后两个
如果中>后,必定l = mid + 1
如果中<后,必定r = mid
其余绥靖政策 r -= 1
ac code
class Solution:
def findMin(self, nums: List[int]) -> int:
n = len(nums)
l, r = 0, n - 1
# 旋转排序数组的中后定位法
while l < r:
mid = (l + r) // 2
if nums[mid] < nums[r]:
r = mid
elif nums[mid] > nums[r]:
l = mid + 1
else:
r -= 1
return nums[l]
总结
经典旋转排序数组二分
边栏推荐
- BSC smart chain contract mode system development details
- Leetcode - 359 log rate limiter (Design)
- 共享锁(Shared Lock)
- MySQL乐观锁
- Is there only one lib under JDBC in Seata?
- Idea - click the file code to automatically synchronize with the directory
- No tracked branch configured for branch xxx or the branch doesn‘t exist. To make your branch trac
- 报表工具的二次革命
- Matlab -- CVX optimization kit installation
- Recommended collection, which is probably the most comprehensive coding method summary of category type features
猜你喜欢

面试8家公司,1周拿了5个offer,分享一下自己的心得

Huawei 2023 starts to warm up in advance! Zuo Shen's program code interview guide comes in handy

Recommended collection, which is probably the most comprehensive coding method summary of category type features

Redis distributed lock, it's really impossible without it

推荐收藏,这或许是最全的类别型特征的编码方法总结

Leetcode - 303 area and retrieval - array immutable (design prefix and array)

Introduction to redis

Why is preparestatement better and safer?

Pytoch learning notes - Teacher Liu Er RNN advanced chapter - code comments and results

LeetCode - 641 设计循环双端队列(设计)*
随机推荐
The second revolution of reporting tools
不愧是阿里内部“千亿级并发系统架构设计笔记”面面俱到,太全了
Circulaindicator component, which makes the indicator style more diversified
Okaleido上线聚变Mining模式,OKA通证当下产出的唯一方式
如何构建面向海量数据、高实时要求的企业级OLAP数据引擎?
The difference between VaR, let and Const
Use cpolar to build a business website (how to buy a domain name)
Pytoch learning notes -- Summary of common functions 3
权限管理-删除菜单(递归)
MySQL - Summary of common SQL statements
Redis分布式锁,没它真不行
微信小程序
MySQL tutorial 66 data table query statement
没错,请求DNS服务器还可以使用UDP协议
Leetcode - 707 design linked list (Design)
R语言ggplot2可视化线图(line)、自定义配置标题文本相关内容颜色和图例(legend)颜色相匹配(和分组线图的颜色相匹配、match colors of groups)
CVPR 2022 | 网络中批处理归一化估计偏移的深入研究
Pytoch learning notes -- Summary of common functions of pytoch 1
Leetcode - 225 implements stack with queue
Why is preparestatement better and safer?