mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-03-14 16:22:24 +08:00
31 lines
1.1 KiB
HTML
31 lines
1.1 KiB
HTML
<p>给你一个整数数组 <code>nums</code> ,请你找出数组中乘积最大的非空连续 <span data-keyword="subarray-nonempty">子数组</span>(该子数组中至少包含一个数字),并返回该子数组所对应的乘积。</p>
|
|
|
|
<p>测试用例的答案是一个 <strong>32-位</strong> 整数。</p>
|
|
|
|
<p> </p>
|
|
|
|
<p><strong class="example">示例 1:</strong></p>
|
|
|
|
<pre>
|
|
<strong>输入:</strong> nums = [2,3,-2,4]
|
|
<strong>输出:</strong> <code>6</code>
|
|
<strong>解释:</strong> 子数组 [2,3] 有最大乘积 6。
|
|
</pre>
|
|
|
|
<p><strong class="example">示例 2:</strong></p>
|
|
|
|
<pre>
|
|
<strong>输入:</strong> nums = [-2,0,-1]
|
|
<strong>输出:</strong> 0
|
|
<strong>解释:</strong> 结果不能为 2, 因为 [-2,-1] 不是子数组。</pre>
|
|
|
|
<p> </p>
|
|
|
|
<p><strong>提示:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>1 <= nums.length <= 2 * 10<sup>4</sup></code></li>
|
|
<li><code>-10 <= nums[i] <= 10</code></li>
|
|
<li><code>nums</code> 的任何子数组的乘积都 <strong>保证</strong> 是一个 <strong>32-位</strong> 整数</li>
|
|
</ul>
|