python MaxDoubleSliceSum

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python MaxDoubleSliceSum相关的知识,希望对你有一定的参考价值。

# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")

def solution(A):
    # write your code in Python 3.6
    k1 = [0] * len(A)
    k2 = [0] * len(A)
    for i, a in enumerate(A[1:]):
        k1[i+1] = max(k1[i] + a, 0, a)
    for i, a in enumerate(A[::-1][1:]):
        k2[-2-i] = max(k2[-1-i] + a, 0, a)
    return max(k1[i-1] + k2[i+1] for i in range(1, len(A) - 1))

以上是关于python MaxDoubleSliceSum的主要内容,如果未能解决你的问题,请参考以下文章

Codility---MaxDoubleSliceSum

MaxDoubleSliceSum Codility 算法

代写python,代写python编程,python代写,python编程代写,留学生python代写

001--python全栈--基础知识--python安装

Python代写,Python作业代写,代写Python,代做Python

Python开发