[codility]TapeEquilibrium

Python代码如下:

def solution(A):
    # write your code in Python 2.6
    arraySum = sum(A)
    globalMinDiff = sys.maxint
    curSum = 0
    for i in xrange(0, len(A)-1):
        curSum += A[i]
        globalMinDiff = min(globalMinDiff, abs(arraySum-2*curSum))
    return globalMinDiff


你可能感兴趣的:([codility]TapeEquilibrium)