fix findmax for three test cases #1 fix1 #14
1 changed files with 6 additions and 2 deletions
|
@ -7,9 +7,13 @@ def find_maxima(x):
|
|||
Output:
|
||||
idx -- list of indices of the local maxima in x
|
||||
"""
|
||||
return []
|
||||
idx = []
|
||||
for i in range(1, len(x)-1):
|
||||
if (x[i] > x[i-1]) & (x[i] > x[i+1]):
|
||||
idx.append(i)
|
||||
return idx
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
x = [1, 2, 3]
|
||||
x = [1, 3, -2, 0, 2, 1]
|
||||
print(find_maxima(x))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue