剑指offer42 连续子数组的最大和
题目描述
输入一个整型数组,数组中的一个或连续多个整数组成一个子数组。求所有子数组的和的最大值。
要求时间复杂度为O(n)。
示例1:
1 | 输入: nums = [-2,1,-3,4,-1,2,1,-5,4] |
提示:
1 <= arr.length <= 10^5
-100 <= arr[i] <= 100
解题思路
方法一:动态规划
代码实现
1 | static class Solution42 { |
复杂度分析
时间复杂度:
空间复杂度:
资料
https://leetcode-cn.com/problems/lian-xu-zi-shu-zu-de-zui-da-he-lcof/
剑指offer42 连续子数组的最大和
You need to set
install_url
to use ShareThis. Please set it in _config.yml
.