1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-22 05:26:46 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给你一个整数数组&nbsp;<code>nums</code>&nbsp;和一个整数&nbsp;<code>k</code>&nbsp;,请你返回 <strong>非空</strong>&nbsp;子序列元素和的最大值,子序列需要满足:子序列中每两个 <strong>相邻</strong>&nbsp;的整数&nbsp;<code>nums[i]</code>&nbsp;和&nbsp;<code>nums[j]</code>&nbsp;,它们在原数组中的下标&nbsp;<code>i</code>&nbsp;和&nbsp;<code>j</code>&nbsp;满足&nbsp;<code>i &lt; j</code>&nbsp;且 <code>j - i &lt;= k</code> 。</p>\n\n<p>数组的子序列定义为:将数组中的若干个数字删除(可以删除 0 个数字),剩下的数字按照原本的顺序排布。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre><strong>输入:</strong>nums = [10,2,-10,5,20], k = 2\n<strong>输出:</strong>37\n<strong>解释:</strong>子序列为 [10, 2, 5, 20] 。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre><strong>输入:</strong>nums = [-1,-2,-3], k = 1\n<strong>输出:</strong>-1\n<strong>解释:</strong>子序列必须是非空的,所以我们选择最大的数字。\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre><strong>输入:</strong>nums = [10,-2,-10,-5,20], k = 2\n<strong>输出:</strong>23\n<strong>解释:</strong>子序列为 [10, -2, -5, 20] 。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= k &lt;= nums.length &lt;= 10^5</code></li>\n\t<li><code>-10^4&nbsp;&lt;= nums[i] &lt;= 10^4</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Hard",
"likes": 93,
"likes": 97,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -167,7 +167,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"3.9K\", \"totalSubmission\": \"8.6K\", \"totalAcceptedRaw\": 3885, \"totalSubmissionRaw\": 8573, \"acRate\": \"45.3%\"}",
"stats": "{\"totalAccepted\": \"4.1K\", \"totalSubmission\": \"9K\", \"totalAcceptedRaw\": 4079, \"totalSubmissionRaw\": 9002, \"acRate\": \"45.3%\"}",
"hints": [
"Use dynamic programming.",
"Let dp[i] be the solution for the prefix of the array that ends at index i, if the element at index i is in the subsequence.",