mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 19:53:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			31 lines
		
	
	
		
			1015 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			1015 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>某公司每日销售额记于整数数组 <code>sales</code>,请返回所有 <strong>连续</strong> 一或多天销售额总和的最大值。</p>
 | 
						||
 | 
						||
<p>要求实现时间复杂度为 <code>O(n)</code> 的算法。</p>
 | 
						||
 | 
						||
<p> </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。 </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>
 |