leetcode1031】的更多相关文章

Given an array A of non-negative integers, return the maximum sum of elements in two non-overlapping (contiguous) subarrays, which have lengths L and M.  (For clarification, the L-length subarray could occur before or after the M-length subarray.) Fo…
class Solution(object): def getMaxByCount(self,A,maxlen): curmax = 0 curmax = sum(A[:maxlen]) bigmax = curmax n = len(A) for i in range(maxlen,n): curmax = curmax-A[i-maxlen]+A[i] if curmax > bigmax: bigmax = curmax return bigmax def maxSumTwoNoOverl…