Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
16 lines (16 sloc) 431 Bytes
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/9/2 4:40 PM
# @Author : Slade
# @File : LeetCode53maximum-subarray.py.py
class Solution(object):
def maxSubArray(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
dp = [0]*len(nums)
dp[0] = nums[0]
for i in range(1,len(nums)):
dp[i] = max(dp[i-1]+nums[i],nums[i])
return max(dp)
You can’t perform that action at this time.