1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-02 22:13:28 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-03-29 16:56:27 +08:00
parent e730aa6794
commit ad15da05aa
2517 changed files with 7358 additions and 7332 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给你一个正整数数组 <code>arr</code> 。请你对 <code>arr</code> 执行一些操作(也可以不进行任何操作),使得数组满足以下条件:</p>\n\n<ul>\n\t<li><code>arr</code> 中 <strong>第一个</strong> 元素必须为 <code>1</code> 。</li>\n\t<li>任意相邻两个元素的差的绝对值 <strong>小于等于</strong> <code>1</code> ,也就是说,对于任意的 <code>1 <= i < arr.length</code> <strong>数组下标从 0 开始</strong>),都满足 <code>abs(arr[i] - arr[i - 1]) <= 1</code> 。<code>abs(x)</code> 为 <code>x</code> 的绝对值。</li>\n</ul>\n\n<p>你可以执行以下 2 种操作任意次:</p>\n\n<ul>\n\t<li><strong>减小</strong> <code>arr</code> 中任意元素的值,使其变为一个 <strong>更小的正整数</strong> 。</li>\n\t<li><strong>重新排列</strong> <code>arr</code> 中的元素,你可以以任意顺序重新排列。</li>\n</ul>\n\n<p>请你返回执行以上操作后,在满足前文所述的条件下,<code>arr</code> 中可能的 <strong>最大值</strong> 。</p>\n\n<p> </p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<b>输入:</b>arr = [2,2,1,2,1]\n<b>输出:</b>2\n<b>解释:</b>\n我们可以重新排列 arr 得到 <code>[1,2,2,2,1] ,该数组满足所有条件。</code>\narr 中最大元素为 2 。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<b>输入:</b>arr = [100,1,1000]\n<b>输出:</b>3\n<b>解释:</b>\n一个可行的方案如下\n1. 重新排列 <code>arr</code> 得到 <code>[1,100,1000] 。</code>\n2. 将第二个元素减小为 2 。\n3. 将第三个元素减小为 3 。\n现在 <code>arr = [1,2,3] ,满足所有条件。</code>\narr 中最大元素为 3 。\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre>\n<b>输入:</b>arr = [1,2,3,4,5]\n<b>输出:</b>5\n<b>解释:</b>数组已经满足所有条件,最大元素为 5 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= arr.length <= 10<sup>5</sup></code></li>\n\t<li><code>1 <= arr[i] <= 10<sup>9</sup></code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 71,
"likes": 72,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -149,7 +149,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"28.6K\", \"totalSubmission\": \"45.3K\", \"totalAcceptedRaw\": 28603, \"totalSubmissionRaw\": 45258, \"acRate\": \"63.2%\"}",
"stats": "{\"totalAccepted\": \"28.6K\", \"totalSubmission\": \"45.3K\", \"totalAcceptedRaw\": 28616, \"totalSubmissionRaw\": 45279, \"acRate\": \"63.2%\"}",
"hints": [
"Sort the Array.",
"Decrement each element to the largest integer that satisfies the conditions."