Allow equality of neighbors for maxima
This commit is contained in:
parent
7c2448f2da
commit
c14f7b84d5
1 changed files with 3 additions and 3 deletions
|
@ -9,12 +9,12 @@ def find_maxima(x):
|
|||
"""
|
||||
sol = []
|
||||
for idx, num in enumerate(x):
|
||||
if idx == 0 and num > x[idx+1]:
|
||||
if idx == 0 and num => x[idx+1]:
|
||||
sol.append(idx)
|
||||
elif idx == len(x)-1 and num > x[idx-1]:
|
||||
elif idx == len(x)-1 and num => x[idx-1]:
|
||||
sol.append(idx)
|
||||
else:
|
||||
if x[idx-1] < num and num > x[idx+1]:
|
||||
if x[idx-1] <= num and num => x[idx+1]:
|
||||
sol.append(idx)
|
||||
|
||||
return sol
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue