mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-22 21:46:46 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个整数数组 <code>arr</code>,请你将该数组分隔为长度最多为 k 的一些(连续)子数组。分隔完成后,每个子数组的中的所有值都会变为该子数组中的最大值。</p>\n\n<p>返回将数组分隔变换后能够得到的元素最大和。</p>\n\n<p> </p>\n\n<p><strong>注意,</strong>原数组和分隔后的数组对应顺序应当一致,也就是说,你只能选择分隔数组的位置而不能调整数组中的顺序。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>arr = [1,15,7,9,2,5,10], k = 3\n<strong>输出:</strong>84\n<strong>解释:</strong>\n因为 k=3 可以分隔成 [1,15,7] [9] [2,5,10],结果为 [15,15,15,9,10,10,10],和为 84,是该数组所有分隔变换后元素总和最大的。\n若是分隔成 [1] [15,7,9] [2,5,10],结果就是 [1, 15, 15, 15, 10, 10, 10] 但这种分隔方式的元素总和(76)小于上一种。 </pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong>arr = [1,4,1,5,7,3,6,1,9,9,3], k = 4\n<strong>输出:</strong>83\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre>\n<strong>输入:</strong>arr = [1], k = 1\n<strong>输出:</strong>1\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= arr.length <= 500</code></li>\n\t<li><code>0 <= arr[i] <= 10<sup>9</sup></code></li>\n\t<li><code>1 <= k <= arr.length</code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 137,
|
||||
"likes": 138,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -143,7 +143,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"9K\", \"totalSubmission\": \"13K\", \"totalAcceptedRaw\": 9038, \"totalSubmissionRaw\": 12962, \"acRate\": \"69.7%\"}",
|
||||
"stats": "{\"totalAccepted\": \"9.1K\", \"totalSubmission\": \"13K\", \"totalAcceptedRaw\": 9050, \"totalSubmissionRaw\": 12979, \"acRate\": \"69.7%\"}",
|
||||
"hints": [
|
||||
"Think dynamic programming: dp[i] will be the answer for array A[0], ..., A[i-1].",
|
||||
"For j = 1 .. k that keeps everything in bounds, dp[i] is the maximum of dp[i-j] + max(A[i-1], ..., A[i-j]) * j ."
|
||||
|
||||
Reference in New Issue
Block a user