1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-07 00:11:41 +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>x</code>&nbsp;的 <strong>权重</strong> 定义为按照下述规则将 <code>x</code>&nbsp;变成 <code>1</code>&nbsp;所需要的步数:</p>\n\n<ul>\n\t<li>如果&nbsp;<code>x</code>&nbsp;是偶数,那么&nbsp;<code>x = x / 2</code></li>\n\t<li>如果&nbsp;<code>x</code>&nbsp;是奇数,那么&nbsp;<code>x = 3 * x + 1</code></li>\n</ul>\n\n<p>比方说x=3 的权重为 7 。因为 3 需要 7 步变成 1 3 --&gt; 10 --&gt; 5 --&gt; 16 --&gt; 8 --&gt; 4 --&gt; 2 --&gt; 1。</p>\n\n<p>给你三个整数&nbsp;<code>lo</code>&nbsp;<code>hi</code> 和&nbsp;<code>k</code>&nbsp;。你的任务是将区间&nbsp;<code>[lo, hi]</code>&nbsp;之间的整数按照它们的权重&nbsp;<strong>升序排序&nbsp;</strong>,如果大于等于 2 个整数有&nbsp;<strong>相同</strong>&nbsp;的权重,那么按照数字自身的数值&nbsp;<strong>升序排序</strong>&nbsp;。</p>\n\n<p>请你返回区间&nbsp;<code>[lo, hi]</code>&nbsp;之间的整数按权重排序后的第&nbsp;<code>k</code>&nbsp;个数。</p>\n\n<p>注意,题目保证对于任意整数&nbsp;<code>x</code>&nbsp;<code>lo &lt;= x &lt;= hi</code>&nbsp;,它变成&nbsp;<code>1</code> 所需要的步数是一个 32 位有符号整数。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>lo = 12, hi = 15, k = 2\n<strong>输出:</strong>13\n<strong>解释:</strong>12 的权重为 912 --&gt; 6 --&gt; 3 --&gt; 10 --&gt; 5 --&gt; 16 --&gt; 8 --&gt; 4 --&gt; 2 --&gt; 1\n13 的权重为 9\n14 的权重为 17\n15 的权重为 17\n区间内的数按权重排序以后的结果为 [12,13,14,15] 。对于 k = 2 ,答案是第二个整数也就是 13 。\n注意12 和 13 有相同的权重所以我们按照它们本身升序排序。14 和 15 同理。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>lo = 7, hi = 11, k = 4\n<strong>输出:</strong>7\n<strong>解释:</strong>区间内整数 [7, 8, 9, 10, 11] 对应的权重为 [16, 3, 19, 6, 14] 。\n按权重排序后得到的结果为 [8, 10, 11, 7, 9] 。\n排序后数组中第 4 个数字为 7 。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= lo &lt;= hi &lt;= 1000</code></li>\n\t<li><code>1 &lt;= k &lt;= hi - lo + 1</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 44,
"likes": 45,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -149,7 +149,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"11K\", \"totalSubmission\": \"15.9K\", \"totalAcceptedRaw\": 11024, \"totalSubmissionRaw\": 15864, \"acRate\": \"69.5%\"}",
"stats": "{\"totalAccepted\": \"11K\", \"totalSubmission\": \"15.9K\", \"totalAcceptedRaw\": 11034, \"totalSubmissionRaw\": 15878, \"acRate\": \"69.5%\"}",
"hints": [
"Use dynamic programming to get the power of each integer of the intervals.",
"Sort all the integers of the interval by the power value and return the k-th in the sorted list."