2024-05-28发表2025-01-15更新LeetCode每日一题几秒读完 (大约69个字)0次访问2951. 找出峰值找出峰值 难度: easy 原始链接: https://leetcode.cn/problems/find-the-peaks 标签: 循环 解法一: 循环go1234567891011func findPeaks(mountain []int) []int { ans := []int{} n := len(mountain) for i := 1; i < n-1; i++ { if mountain[i] > mountain[i-1] && mountain[i] > mountain[i+1] { ans = append(ans, i) i++ } } return ans} 2951. 找出峰值https://wuhunyu.top/leetcode/2024/05/find-the-peaks/index.html作者wuhunyu发布于2024-05-28更新于2025-01-15许可协议#循环