mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
25 lines
762 B
HTML
25 lines
762 B
HTML
<p>输入一个整型数组,数组中的一个或连续多个整数组成一个子数组。求所有子数组的和的最大值。</p>
|
|
|
|
<p>要求时间复杂度为O(n)。</p>
|
|
|
|
<p> </p>
|
|
|
|
<p><strong>示例1:</strong></p>
|
|
|
|
<pre><strong>输入:</strong> nums = [-2,1,-3,4,-1,2,1,-5,4]
|
|
<strong>输出:</strong> 6
|
|
<strong>解释:</strong> 连续子数组 [4,-1,2,1] 的和最大,为 6。</pre>
|
|
|
|
<p> </p>
|
|
|
|
<p><strong>提示:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>1 <= arr.length <= 10^5</code></li>
|
|
<li><code>-100 <= arr[i] <= 100</code></li>
|
|
</ul>
|
|
|
|
<p>注意:本题与主站 53 题相同:<a href="https://leetcode-cn.com/problems/maximum-subarray/">https://leetcode-cn.com/problems/maximum-subarray/</a></p>
|
|
|
|
<p> </p>
|