mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-03 06:22:54 +08:00
update
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "2323",
|
||||
"questionFrontendId": "6033",
|
||||
"questionFrontendId": "2220",
|
||||
"categoryTitle": "Algorithms",
|
||||
"boundTopicId": 1385551,
|
||||
"title": "Minimum Bit Flips to Convert Number",
|
||||
@@ -12,13 +12,20 @@
|
||||
"translatedContent": "<p>一次 <strong>位翻转</strong> 定义为将数字 <code>x</code> 二进制中的一个位进行 <strong>翻转</strong> 操作,即将 <code>0</code> 变成 <code>1</code> ,或者将 <code>1</code> 变成 <code>0</code> 。</p>\n\n<ul>\n\t<li>比方说,<code>x = 7</code> ,二进制表示为 <code>111</code> ,我们可以选择任意一个位(包含没有显示的前导 0 )并进行翻转。比方说我们可以翻转最右边一位得到 <code>110</code> ,或者翻转右边起第二位得到 <code>101</code> ,或者翻转右边起第五位(这一位是前导 0 )得到 <code>10111</code> 等等。</li>\n</ul>\n\n<p>给你两个整数 <code>start</code> 和 <code>goal</code> ,请你返回将 <code>start</code> 转变成 <code>goal</code> 的 <strong>最少位翻转</strong> 次数。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<b>输入:</b>start = 10, goal = 7\n<b>输出:</b>3\n<b>解释:</b>10 和 7 的二进制表示分别为 1010 和 0111 。我们可以通过 3 步将 10 转变成 7 :\n- 翻转右边起第一位得到:101<strong><em>0</em></strong> -> 101<strong><em>1 。</em></strong>\n- 翻转右边起第三位:1<strong><em>0</em></strong>11 -> 1<strong><em>1</em></strong>11 。\n- 翻转右边起第四位:<strong><em>1</em></strong>111 -> <strong><em>0</em></strong>111 。\n我们无法在 3 步内将 10 转变成 7 。所以我们返回 3 。</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<b>输入:</b>start = 3, goal = 4\n<b>输出:</b>3\n<b>解释:</b>3 和 4 的二进制表示分别为 011 和 100 。我们可以通过 3 步将 3 转变成 4 :\n- 翻转右边起第一位:01<strong><em>1</em></strong> -> 01<em><strong>0 </strong></em>。\n- 翻转右边起第二位:0<strong><em>1</em></strong>0 -> 0<strong><em>0</em></strong>0 。\n- 翻转右边起第三位:<strong><em>0</em></strong>00 -> <strong><em>1</em></strong>00 。\n我们无法在 3 步内将 3 变成 4 。所以我们返回 3 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>0 <= start, goal <= 10<sup>9</sup></code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 3,
|
||||
"likes": 4,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"contributors": [],
|
||||
"langToValidPlayground": "{\"cpp\": true, \"java\": true, \"python\": true, \"python3\": true, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}",
|
||||
"topicTags": [],
|
||||
"topicTags": [
|
||||
{
|
||||
"name": "Bit Manipulation",
|
||||
"slug": "bit-manipulation",
|
||||
"translatedName": "位运算",
|
||||
"__typename": "TopicTagNode"
|
||||
}
|
||||
],
|
||||
"companyTagStats": null,
|
||||
"codeSnippets": [
|
||||
{
|
||||
@@ -130,7 +137,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"4.1K\", \"totalSubmission\": \"5K\", \"totalAcceptedRaw\": 4057, \"totalSubmissionRaw\": 4990, \"acRate\": \"81.3%\"}",
|
||||
"stats": "{\"totalAccepted\": \"5.5K\", \"totalSubmission\": \"6.7K\", \"totalAcceptedRaw\": 5534, \"totalSubmissionRaw\": 6684, \"acRate\": \"82.8%\"}",
|
||||
"hints": [
|
||||
"If the value of a bit in start and goal differ, then we need to flip that bit.",
|
||||
"Consider using the XOR operation to determine which bits need a bit flip."
|
||||
|
Reference in New Issue
Block a user