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)/三个无重叠子数组的最大和 [maximum-sum-of-3-non-overlapping-subarrays].html
2022-03-29 12:43:11 +08:00

32 lines
1.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个整数数组 <code>nums</code> 和一个整数 <code>k</code> ,找出三个长度为 <code>k</code> 、互不重叠、且全部数字和(<code>3 * k</code> 项)最大的子数组,并返回这三个子数组。</p>
<p>以下标的数组形式返回结果,数组中的每一项分别指示每个子数组的起始位置(下标从 <strong>0</strong> 开始)。如果有多个结果,返回字典序最小的一个。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [1,2,1,2,6,7,5,1], k = 2
<strong>输出:</strong>[0,3,5]
<strong>解释:</strong>子数组 [1, 2], [2, 6], [7, 5] 对应的起始下标为 [0, 3, 5]。
也可以取 [2, 1], 但是结果 [1, 3, 5] 在字典序上更大。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [1,2,1,2,1,2,1,2,1], k = 2
<strong>输出:</strong>[0,2,4]
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 2 * 10<sup>4</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;&nbsp;2<sup>16</sup></code></li>
<li><code>1 &lt;= k &lt;= floor(nums.length / 3)</code></li>
</ul>