力扣 53. 最大子数组和

动态规划

1
2
3
4
5
6
def maxSubArray(nums):
cur, ret = float("-inf"), float("-inf")
for n in nums:
cur = max(n, cur + n)
ret = max(cur, ret)
return ret
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2022 eightyninth
  • Visitors: | Views:

请我喝杯咖啡吧~

支付宝
微信