面试题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

  

posted @ 2019-08-05 11:58  lililili——  阅读(149)  评论(0)    收藏  举报