Skip to main content

20240528 2951 - Easy - Array

2951. Find the Peaks

class Solution:
def findPeaks(self, mountain: List[int]) -> List[int]:
ans = []
pre = mountain[0]
i = 1
while i < len(mountain) - 1:
if pre < mountain[i] and mountain[i] > mountain[i+1]:
ans.append(i)
pre = mountain[i]
i+=1
return ans