题目:Find the contiguous subarray within an array (containing at least one number) which has the largest sum. 最大子列和
思路:在线搜索O(n)
class Solution(object):
def maxSubArray(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
s = None;c = 0;j=0
while j<len(nums):
c+=nums[j]
if c>s or s==None:
s = c
if c<0:
c=0
j+=1
return s