2019-06-29 自我修养►数据结构与算法 求最大子数组---python实现 动态规划求一个数组的最大子数组。 1234567891011121314def max_sub_array(a): sum, max, start, new_start, end = a[0], a[0], 0, 0, 0 for i, e in enumerate(a[1:], 1): if sum <= 0: new_start = i sum = e else: sum += e if sum > max: start = new_start end = i max = sum return start, end, max Newer 4.Median of Two Sorted Arrays Older 3.Longest Substring Without Repeating Characters