思路同:求数组中子数组的最大和
代码:
In [1]: def get_longest_decrease_sub_array(array):
...: cur_list = max_list = array[0:1]
...: for i in range(1,len(array)):
...: if array[i]<array[i-1]:
...: cur_list.append(array[i])
...: else:
...: cur_list=[array[i]]
...: if len(cur_list)>len(max_list):
...: max_list=cur_list
...: return max_list
...:
In [2]: get_longest_decrease_sub_array([9,3,-1,6,5,3,1,8,5,2,7,1])
Out[2]: [6, 5, 3, 1]