📜  kadane 算法 - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:45.486000             🧑  作者: Mango

代码示例3
def kadane(inputArray):
    maxSum = float("-inf")
    curSum = 0
    
    for x in inputArray:
          curSum = max(0, curSum + x)
          maxSum = max(maxSum, curSum)
    return maxSum