当前位置:网站首页>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 剑指offer 10-I.斐波那契数列(简单)

2022李宏毅机器学习hw1--COVID-19 Cases Prediction

图片批量添加水印批量加背景缩放批量合并工具picUnionV4.0

链读 | 最新最全的数字藏品发售日历-07.28

Batch add watermark to pictures batch add background zoom batch merge tool picUnionV4.0

国内数字藏品投资价值分析

Collection set interface

Link reading good article: What is the difference between hot encrypted storage and cold encrypted storage?

Ten years of sharpening a sword!The digital collection market software, Link Reading APP is officially open for internal testing!

最新最全的数字藏品发售日历-07.26
随机推荐
微信小程序wx.writeBLECharacteristicValue汉字转buffer问题
R语言聚类分析——代码解析
Set Sources Resources and other folders in the IDEA project
LeetCode 剑指offer 10-I.斐波那契数列(简单)
network security firewall
Operation table Function usage
LeetCode 94.二叉树的中序遍历(简单)
【笔记】集合框架体系 Collection
最新最全的数字藏品发售日历-07.26
LeetCode 1720.解码异或后的数组(简单)
小程序wx.request简单Promise封装
Linux数据库Oracle客户端安装,用于shell脚本用sqlplus连接数据库
GUI_AWT
cesium rotate image
反射【笔记】
pytorch-05.用pytorch实现线性回归
Likou - Number of Provinces
智能合约和去中心化应用DAPP
Timer (setInterval) on and off
笔记1