当前位置:网站首页>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]
总结
经典旋转排序数组二分
边栏推荐
- Leetcode - 379 telephone directory management system (Design)
- Mysql读写锁
- R语言使用gt包和gtExtras包漂亮地显示表格数据:gt_bar_plot函数和gt_plt_bar_pct函数可视化百分比条形图、原始数据的百分比条形、缩放后的数据的百分比条形、指定数据对齐宽度
- MySQL tutorial 65 data in MySQL operation table
- Storage structure of cross linked list
- JVM - classloader and parental delegation model
- LeetCode - 232 用栈实现队列 (设计 双栈实现队列)
- # JWT 图解
- Leetcode - 622 design cycle queue (Design)
- 兆骑科创高质量海归人才双创服务平台,线上直播路演
猜你喜欢

ML - Speech - traditional speech model

How matlab saves all the data after running

ML - Speech - Introduction to speech processing

共2600页!又一份神级的面试手册面世~

Okaleido launched the fusion mining mode, which is the only way for Oka to verify the current output

LeetCode - 359 日志速率限制器 (设计)

Leetcode - 677 key value mapping (Design)*

LeetCode - 232 用栈实现队列 (设计 双栈实现队列)

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

LeetCode - 641 设计循环双端队列(设计)*
随机推荐
Huawei 2023 starts to warm up in advance! Zuo Shen's program code interview guide comes in handy
兆骑科创海内外高层次创新创业人才服务平台,双创成果转化平台
Pytoch learning notes -- Summary of common functions of pytoch 1
LeetCode - 362 敲击计数器(设计)
百奥赛图与LiberoThera共同开发全人GPCR抗体药物取得里程碑式进展
Gary marcus: learning a language is more difficult than you think
LeetCode - 359 日志速率限制器 (设计)
Leetcode - 707 design linked list (Design)
Where is there a demo to set up the flex CDC to draw the number of MySQL?
mysql 隔离级别事务
MySQL tutorial 71-where conditional query data
Solve the vender-base.66c6fc1c0b393478adf7.js:6 typeerror: cannot read property 'validate' of undefined problem
权限管理-删除菜单(递归)
BSC smart chain contract mode system development details
Okaleido上线聚变Mining模式,OKA通证当下产出的唯一方式
一文入门Redis
Leetcode - 362 knock counter (Design)
Understand "average load"
Boomi荣获“多元化最佳首席执行官奖”和“职业成长最佳公司奖”,在大型公司类别中跻身50强
ServletConfig 类和ServletContext 类