Allow equality of neighbors for maxima

This commit is contained in:
ASPP Student 2025-09-23 16:26:51 +03:00
parent 7c2448f2da
commit c14f7b84d5

View file

@ -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