mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-07 00:11:41 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>我们将整数 <code>x</code> 的 <strong>权重</strong> 定义为按照下述规则将 <code>x</code> 变成 <code>1</code> 所需要的步数:</p>\n\n<ul>\n\t<li>如果 <code>x</code> 是偶数,那么 <code>x = x / 2</code></li>\n\t<li>如果 <code>x</code> 是奇数,那么 <code>x = 3 * x + 1</code></li>\n</ul>\n\n<p>比方说,x=3 的权重为 7 。因为 3 需要 7 步变成 1 (3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1)。</p>\n\n<p>给你三个整数 <code>lo</code>, <code>hi</code> 和 <code>k</code> 。你的任务是将区间 <code>[lo, hi]</code> 之间的整数按照它们的权重 <strong>升序排序 </strong>,如果大于等于 2 个整数有 <strong>相同</strong> 的权重,那么按照数字自身的数值 <strong>升序排序</strong> 。</p>\n\n<p>请你返回区间 <code>[lo, hi]</code> 之间的整数按权重排序后的第 <code>k</code> 个数。</p>\n\n<p>注意,题目保证对于任意整数 <code>x</code> <code>(lo <= x <= hi)</code> ,它变成 <code>1</code> 所需要的步数是一个 32 位有符号整数。</p>\n\n<p> </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 的权重为 9(12 --> 6 --> 3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 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> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= lo <= hi <= 1000</code></li>\n\t<li><code>1 <= k <= 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."
|
||||
|
Reference in New Issue
Block a user