mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-06 16:01:41 +08:00
存量题库数据更新
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
<p>You are given two integer arrays <code>nums</code> and <code>multipliers</code><strong> </strong>of size <code>n</code> and <code>m</code> respectively, where <code>n >= m</code>. The arrays are <strong>1-indexed</strong>.</p>
|
||||
<p>You are given two <strong>0-indexed</strong> integer arrays <code>nums</code> and <code>multipliers</code><strong> </strong>of size <code>n</code> and <code>m</code> respectively, where <code>n >= m</code>.</p>
|
||||
|
||||
<p>You begin with a score of <code>0</code>. You want to perform <strong>exactly</strong> <code>m</code> operations. On the <code>i<sup>th</sup></code> operation <strong>(1-indexed)</strong>, you will:</p>
|
||||
<p>You begin with a score of <code>0</code>. You want to perform <strong>exactly</strong> <code>m</code> operations. On the <code>i<sup>th</sup></code> operation (<strong>0-indexed</strong>) you will:</p>
|
||||
|
||||
<ul>
|
||||
<li>Choose one integer <code>x</code> from <strong>either the start or the end </strong>of the array <code>nums</code>.</li>
|
||||
<li>Add <code>multipliers[i] * x</code> to your score.</li>
|
||||
<li>Remove <code>x</code> from the array <code>nums</code>.</li>
|
||||
<li>Choose one integer <code>x</code> from <strong>either the start or the end </strong>of the array <code>nums</code>.</li>
|
||||
<li>Add <code>multipliers[i] * x</code> to your score.
|
||||
<ul>
|
||||
<li>Note that <code>multipliers[0]</code> corresponds to the first operation, <code>multipliers[1]</code> to the second operation, and so on.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Remove <code>x</code> from <code>nums</code>.</li>
|
||||
</ul>
|
||||
|
||||
<p>Return <em>the <strong>maximum</strong> score after performing </em><code>m</code> <em>operations.</em></p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums = [1,2,3], multipliers = [3,2,1]
|
||||
@@ -22,7 +26,7 @@
|
||||
- Choose from the end, [<strong><u>1</u></strong>], adding 1 * 1 = 1 to the score.
|
||||
The total score is 9 + 4 + 1 = 14.</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums = [-5,-3,-3,-2,7,1], multipliers = [-10,-5,3,4,6]
|
||||
@@ -42,7 +46,7 @@ The total score is 50 + 15 - 9 + 4 + 42 = 102.
|
||||
<ul>
|
||||
<li><code>n == nums.length</code></li>
|
||||
<li><code>m == multipliers.length</code></li>
|
||||
<li><code>1 <= m <= 10<sup>3</sup></code></li>
|
||||
<li><code>1 <= m <= 300</code></li>
|
||||
<li><code>m <= n <= 10<sup>5</sup></code><code> </code></li>
|
||||
<li><code>-1000 <= nums[i], multipliers[i] <= 1000</code></li>
|
||||
</ul>
|
||||
|
Reference in New Issue
Block a user