1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/连续天数的最高销售额 [lian-xu-zi-shu-zu-de-zui-da-he-lcof].html

31 lines
1011 B
HTML
Raw Normal View History

2023-12-09 18:53:53 +08:00
<p>某公司每日销售额记于整数数组 <code>sales</code>,请返回所有 <strong>连续</strong> 一或多天销售额总和的最大值。</p>
<p>要求实现时间复杂度为 <code>O(n)</code> 的算法。</p>
<p>&nbsp;</p>
<p><strong>示例 1:</strong></p>
<pre>
<strong>输入:</strong>sales = [-2,1,-3,4,-1,2,1,-5,4]
<strong>输出:</strong>6
<strong>解释:</strong>[4,-1,2,1] 此连续四天的销售总额最高,为 6。</pre>
<p><strong>示例 2:</strong></p>
<pre>
<strong>输入:</strong>sales = [5,4,-1,7,8]
<strong>输出:</strong>23
<strong>解释:</strong>[5,4,-1,7,8] 此连续五天的销售总额最高,为 23。&nbsp;</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;=&nbsp;arr.length &lt;= 10^5</code></li>
<li><code>-100 &lt;= arr[i] &lt;= 100</code></li>
</ul>
<p>注意:本题与主站 53 题相同:<a href="https://leetcode-cn.com/problems/maximum-subarray/">https://leetcode-cn.com/problems/maximum-subarray/</a></p>