# # max sum of the subarray # @param arr int整型一维数组 the array # @return int整型 # class Solution: def maxsumofSubarray(self , arr ): # write code here maxv = -1 sumv=0 for i in arr: sumv+=i if sumv<=0: sumv = 0 if sumv>maxv: maxv = sumv return maxv
# # max sum of the subarray # @param arr int整型一维数组 the array # @return int整型 # class Solution: def maxsumofSubarray(self , arr ): # write code here maxv = -1 sumv=0 for i in arr: sumv+=i if sumv<=0: sumv = 0 if sumv>maxv: maxv = sumv return maxv