1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-13 19:31:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

add leetcode problem-cn part1

This commit is contained in:
2022-03-27 20:37:52 +08:00
parent 8e542045d1
commit c554fc6908
1285 changed files with 108123 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
<p>给你一个非负整数&nbsp;<code>num</code>&nbsp;,请你返回将它变成 0 所需要的步数。 如果当前数字是偶数,你需要把它除以 2 ;否则,减去 1 。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>num = 14
<strong>输出:</strong>6
<strong>解释:
</strong>步骤 1) 14 是偶数,除以 2 得到 7 。
步骤 2 7 是奇数,减 1 得到 6 。
步骤 3 6 是偶数,除以 2 得到 3 。
步骤 4 3 是奇数,减 1 得到 2 。
步骤 5 2 是偶数,除以 2 得到 1 。
步骤 6 1 是奇数,减 1 得到 0 。
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>num = 8
<strong>输出:</strong>4
<strong>解释:</strong>
步骤 1 8 是偶数,除以 2 得到 4 。
步骤 2 4 是偶数,除以 2 得到 2 。
步骤 3 2 是偶数,除以 2 得到 1 。
步骤 4 1 是奇数,减 1 得到 0 。
</pre>
<p><strong>示例 3</strong></p>
<pre><strong>输入:</strong>num = 123
<strong>输出:</strong>12
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>0 &lt;= num &lt;= 10^6</code></li>
</ul>