面试题42:连续子数组的最大和

# -*- coding:utf-8 -*-
class Solution:
def FindGreatestSumOfSubArray(self, array):
# write code here
maxNum = None
tempNum = 0
for i in array:
if maxNum == None:
maxNum = i
tempNum +=i
if tempNum < i:
tempNum = i
if maxNum < tempNum:
maxNum = tempNum
return maxNum

浙公网安备 33010602011771号