def FindGreatestSumOfSubArray(dataList): summax = dataList[0] amax = dataList[0] for num in dataList[1:]: amax = max(amax + num, num) summax = max(amax, summax) return summax DP 方法的最大子数组,简洁一些
点赞 1

相关推荐

牛客网
牛客企业服务