mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-21 21:16:45 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个整数 <code>n</code>,你需要重复执行多次下述操作将其转换为 <code>0</code> :</p>\n\n<ul>\n\t<li>翻转 <code>n</code> 的二进制表示中最右侧位(第 <code>0</code> 位)。</li>\n\t<li>如果第 <code>(i-1)</code> 位为 <code>1</code> 且从第 <code>(i-2)</code> 位到第 <code>0</code> 位都为 <code>0</code>,则翻转 <code>n</code> 的二进制表示中的第 <code>i</code> 位。</li>\n</ul>\n\n<p>返回将 <code>n</code> 转换为 <code>0</code> 的最小操作次数。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 3\n<strong>输出:</strong>2\n<strong>解释:</strong>3 的二进制表示为 \"11\"\n\"<strong>1</strong>1\" -> \"<strong>0</strong>1\" ,执行的是第 2 种操作,因为第 0 位为 1 。\n\"0<strong>1</strong>\" -> \"0<strong>0</strong>\" ,执行的是第 1 种操作。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 6\n<strong>输出:</strong>4\n<strong>解释:</strong>6 的二进制表示为 \"110\".\n\"<strong>1</strong>10\" -> \"<strong>0</strong>10\" ,执行的是第 2 种操作,因为第 1 位为 1 ,第 0 到 0 位为 0 。\n\"01<strong>0</strong>\" -> \"01<strong>1</strong>\" ,执行的是第 1 种操作。\n\"0<strong>1</strong>1\" -> \"0<strong>0</strong>1\" ,执行的是第 2 种操作,因为第 0 位为 1 。\n\"00<strong>1</strong>\" -> \"00<strong>0</strong>\" ,执行的是第 1 种操作。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>0 <= n <= 10<sup>9</sup></code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Hard",
|
||||
"likes": 42,
|
||||
"likes": 43,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -149,14 +149,14 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"2.4K\", \"totalSubmission\": \"3.9K\", \"totalAcceptedRaw\": 2389, \"totalSubmissionRaw\": 3895, \"acRate\": \"61.3%\"}",
|
||||
"stats": "{\"totalAccepted\": \"2.4K\", \"totalSubmission\": \"4K\", \"totalAcceptedRaw\": 2433, \"totalSubmissionRaw\": 3954, \"acRate\": \"61.5%\"}",
|
||||
"hints": [
|
||||
"The fastest way to convert n to zero is to remove all set bits starting from the leftmost one. Try some simple examples to learn the rule of how many steps are needed to remove one set bit.",
|
||||
"consider n=2^k case first, then solve for all n."
|
||||
],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
"sampleTestCase": "3",
|
||||
"sampleTestCase": "0",
|
||||
"metaData": "{\n \"name\": \"minimumOneBitOperations\",\n \"params\": [\n {\n \"name\": \"n\",\n \"type\": \"integer\"\n }\n ],\n \"return\": {\n \"type\": \"integer\"\n }\n}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
|
Reference in New Issue
Block a user