leetcode_middle_66_162. Find Peak Element
来源:互联网 发布:剑三病娇正太捏脸数据 编辑:程序博客网 时间:2024/05/17 01:36
题意:
给定一个极大的数组,假设所有数和它左右两个数均不相等。找出一个(数组中可能存在多个)比其左右两个数都大的数。
分析:
遍历,直到满足条件就好了嘛。注意处理好边界特殊情况和一般情况就可以。
public class Solution { public int findPeakElement(int[] nums) { int res = 0; for(int i=0; i<nums.length; i++){ if((i-1==-1 || nums[i-1]<nums[i]) && (i+1==nums.length || nums[i]>nums[i+1])){ res = i; break; } } return res; }}
0 0
- leetcode_middle_66_162. Find Peak Element
- [LeetCode] Find Peak Element
- Find Peak Element
- Leetcode:Find Peak Element
- Find Peak Element
- Find Peak Element
- Find Peak Element
- LeetCode Find Peak Element
- leetcode: Find Peak Element
- leetcode:Find Peak Element
- Find Peak Element
- Find Peak Element
- Find Peak Element
- LeetCode Find Peak Element
- Find Peak Element --leetcode
- Leetcode Find Peak Element
- [LeetCode] Find Peak Element
- Find Peak Element [Medium]
- Skewed Data
- python3中pymysql中将mysql的编码转换为unicode
- linux-编译和添加库和头文件路劲
- 浅谈HTTP请求的过程
- 高性能Linux服务器构建实战 第一章 服务器安全运维
- leetcode_middle_66_162. Find Peak Element
- keepalived +nginx 配置
- 单工,半双工和全双工
- ReactNative键盘遮挡TextInput解决
- 服务器笔记
- 本人gitHub网址
- eclipse中如何删除svn用户名和密码
- 无法嵌入互操作类型“Microsoft.Office.Interop.Word.ApplicationClass”
- 算法第二周