垃圾算法
一个list先递增在递减,求最大值下标
aa = [1, 2, 4, 5, 6, 7, 12, 9, 8, 6, 4, 2, 1]
for i in range(1, len(aa)):
if aa[i-1]<aa[i] and aa[i]>aa[i+1]:
print(i)
如果肯定是正常的山峰list,只要找出aa[i]>aa[i+1]即可
一个list先递增在递减,求最大值下标
aa = [1, 2, 4, 5, 6, 7, 12, 9, 8, 6, 4, 2, 1]
for i in range(1, len(aa)):
if aa[i-1]<aa[i] and aa[i]>aa[i+1]:
print(i)
如果肯定是正常的山峰list,只要找出aa[i]>aa[i+1]即可