mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
32 lines
1.2 KiB
HTML
32 lines
1.2 KiB
HTML
<p>给你一个整数数组 <code>nums</code> <strong>(下标从 0 开始)</strong>和一个整数 <code>k</code> 。</p>
|
||
|
||
<p>一个子数组 <code>(i, j)</code> 的 <strong>分数</strong> 定义为 <code>min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1)</code> 。一个 <strong>好</strong> 子数组的两个端点下标需要满足 <code>i <= k <= j</code> 。</p>
|
||
|
||
<p>请你返回 <strong>好</strong> 子数组的最大可能 <strong>分数</strong> 。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre><b>输入:</b>nums = [1,4,3,7,4,5], k = 3
|
||
<b>输出:</b>15
|
||
<b>解释:</b>最优子数组的左右端点下标是 (1, 5) ,分数为 min(4,3,7,4,5) * (5-1+1) = 3 * 5 = 15 。
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre><b>输入:</b>nums = [5,5,4,5,4,1,1,1], k = 0
|
||
<b>输出:</b>20
|
||
<b>解释:</b>最优子数组的左右端点下标是 (0, 4) ,分数为 min(5,5,4,5,4) * (4-0+1) = 4 * 5 = 20 。
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
|
||
<li><code>1 <= nums[i] <= 2 * 10<sup>4</sup></code></li>
|
||
<li><code>0 <= k < nums.length</code></li>
|
||
</ul>
|