当前位置:网站首页>LeetCode 162. Finding Peaks (Moderate)
LeetCode 162. Finding Peaks (Moderate)
2022-08-10 05:54:00 【Shengxin Research Ape】
python
class Solution:def findPeakElement(self, nums: List[int]) -> int:if(len(nums)==1):return 0if(nums[0]>nums[1]):return 0if(nums[len(nums)-1]>nums[len(nums)-2]):return len(nums)-1'''Complexity O(n)i = 1while(1):if(nums[i]>nums[i-1] and nums[i]>nums[i+1]):breaki +=1return i'''#dichotomyleft = 0right = len(nums)-1while(leftnums[mid+1]):right = midelse:left = mid +1return left 
边栏推荐
- LeetCode 1351.统计有序矩阵中的负数(简单)
- 一个基于.Net Core 开源的物联网基础平台
- Batch add watermark to pictures batch add background zoom batch merge tool picUnionV4.0
- LeetCode 1894.找到需要补充粉笔的学生编号
- win12 modify dns script
- 卷积神经网络(CNN)实现服装图像分类
- 智能合约和去中心化应用DAPP
- 反射【笔记】
- 我不喜欢我的代码
- The complex "metaverse" will be interpreted for you, and the Link Reading APP will be launched soon!
猜你喜欢
随机推荐
Reprint fstream, detailed usage of ifstream
树结构——2-3树图解
程序员副业赚钱之道,实现月收入增加20K
The latest and most complete digital collection sales calendar-07.27
WeChat applet wx.writeBLECharacteristicValue Chinese character to buffer problem
智能合约和去中心化应用DAPP
连接 Nacos 报超时错误
pytorch-05.用pytorch实现线性回归
反射【笔记】
impdp import data
redis常见的面试题
菜谱小程序源码免费分享【推荐】
LeetCode 1720.解码异或后的数组(简单)
并查集原理与API设计
network security firewall
I use this recruit let the team to improve the development efficiency of 100%!
LeetCode 94.二叉树的中序遍历(简单)
【List练习】遍历集合并且按照价格从低到高排序,
LeetCode 2011.执行操作后的变量值(简单)
栈和队列








