mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
42 lines
1.3 KiB
HTML
42 lines
1.3 KiB
HTML
<p>给定一个整数数组 <code>arr</code> 和一个整数 <code>k</code> ,通过重复 <code>k</code> 次来修改数组。</p>
|
||
|
||
<p>例如,如果 <code>arr = [1, 2]</code> ,<meta charset="UTF-8" /> <code>k = 3</code> ,那么修改后的数组将是 <code>[1, 2, 1, 2, 1, 2]</code> 。</p>
|
||
|
||
<p>返回修改后的数组中的最大的子数组之和。注意,子数组长度可以是 <code>0</code>,在这种情况下它的总和也是 <code>0</code>。</p>
|
||
|
||
<p>由于 <strong>结果可能会很大</strong>,需要返回的<meta charset="UTF-8" /> <code>10<sup>9</sup> + 7</code> 的 <strong>模</strong> 。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>arr = [1,2], k = 3
|
||
<strong>输出:</strong>9
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>arr = [1,-2,1], k = 5
|
||
<strong>输出:</strong>2
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>arr = [-1,-2], k = 7
|
||
<strong>输出:</strong>0
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
<meta charset="UTF-8" />
|
||
|
||
<ul>
|
||
<li><code>1 <= arr.length <= 10<sup>5</sup></code></li>
|
||
<li><code>1 <= k <= 10<sup>5</sup></code></li>
|
||
<li><code>-10<sup>4</sup> <= arr[i] <= 10<sup>4</sup></code></li>
|
||
</ul>
|