1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-21 21:16:45 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给定一个正整数&nbsp;<code>n</code> ,你可以做如下操作:</p>\n\n<ol>\n\t<li>如果&nbsp;<code>n</code><em>&nbsp;</em>是偶数,则用&nbsp;<code>n / 2</code>替换&nbsp;<code>n</code><em> </em>。</li>\n\t<li>如果&nbsp;<code>n</code><em>&nbsp;</em>是奇数,则可以用&nbsp;<code>n + 1</code>或<code>n - 1</code>替换&nbsp;<code>n</code> 。</li>\n</ol>\n\n<p>返回 <code>n</code><em>&nbsp;</em>变为 <code>1</code> 所需的 <em>最小替换次数</em> 。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 8\n<strong>输出:</strong>3\n<strong>解释:</strong>8 -&gt; 4 -&gt; 2 -&gt; 1\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 7\n<strong>输出:</strong>4\n<strong>解释:</strong>7 -&gt; 8 -&gt; 4 -&gt; 2 -&gt; 1\n或 7 -&gt; 6 -&gt; 3 -&gt; 2 -&gt; 1\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 4\n<strong>输出:</strong>2\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= n &lt;= 2<sup>31</sup> - 1</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 225,
"likes": 232,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -155,7 +155,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"52.6K\", \"totalSubmission\": \"122.2K\", \"totalAcceptedRaw\": 52591, \"totalSubmissionRaw\": 122179, \"acRate\": \"43.0%\"}",
"stats": "{\"totalAccepted\": \"54K\", \"totalSubmission\": \"125.8K\", \"totalAcceptedRaw\": 54034, \"totalSubmissionRaw\": 125770, \"acRate\": \"43.0%\"}",
"hints": [],
"solution": null,
"status": null,