|
1 | | -<h2><a href="https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero/">1611. Minimum One Bit Operations to Make Integers Zero</a></h2><h3>Hard</h3><hr><div><p>Given an integer <code>n</code>, you must transform it into <code>0</code> using the following operations any number of times:</p> |
| 1 | +<h2><a href="https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero">1732. Minimum One Bit Operations to Make Integers Zero</a></h2><h3>Hard</h3><hr><p>Given an integer <code>n</code>, you must transform it into <code>0</code> using the following operations any number of times:</p> |
2 | 2 |
|
3 | 3 | <ul> |
4 | 4 | <li>Change the rightmost (<code>0<sup>th</sup></code>) bit in the binary representation of <code>n</code>.</li> |
|
10 | 10 | <p> </p> |
11 | 11 | <p><strong class="example">Example 1:</strong></p> |
12 | 12 |
|
13 | | -<pre><strong>Input:</strong> n = 3 |
| 13 | +<pre> |
| 14 | +<strong>Input:</strong> n = 3 |
14 | 15 | <strong>Output:</strong> 2 |
15 | | -<strong>Explanation:</strong> The binary representation of 3 is "11". |
16 | | -"<u>1</u>1" -> "<u>0</u>1" with the 2<sup>nd</sup> operation since the 0<sup>th</sup> bit is 1. |
17 | | -"0<u>1</u>" -> "0<u>0</u>" with the 1<sup>st</sup> operation. |
| 16 | +<strong>Explanation:</strong> The binary representation of 3 is "11". |
| 17 | +"<u>1</u>1" -> "<u>0</u>1" with the 2<sup>nd</sup> operation since the 0<sup>th</sup> bit is 1. |
| 18 | +"0<u>1</u>" -> "0<u>0</u>" with the 1<sup>st</sup> operation. |
18 | 19 | </pre> |
19 | 20 |
|
20 | 21 | <p><strong class="example">Example 2:</strong></p> |
21 | 22 |
|
22 | | -<pre><strong>Input:</strong> n = 6 |
| 23 | +<pre> |
| 24 | +<strong>Input:</strong> n = 6 |
23 | 25 | <strong>Output:</strong> 4 |
24 | | -<strong>Explanation:</strong> The binary representation of 6 is "110". |
25 | | -"<u>1</u>10" -> "<u>0</u>10" with the 2<sup>nd</sup> operation since the 1<sup>st</sup> bit is 1 and 0<sup>th</sup> through 0<sup>th</sup> bits are 0. |
26 | | -"01<u>0</u>" -> "01<u>1</u>" with the 1<sup>st</sup> operation. |
27 | | -"0<u>1</u>1" -> "0<u>0</u>1" with the 2<sup>nd</sup> operation since the 0<sup>th</sup> bit is 1. |
28 | | -"00<u>1</u>" -> "00<u>0</u>" with the 1<sup>st</sup> operation. |
| 26 | +<strong>Explanation:</strong> The binary representation of 6 is "110". |
| 27 | +"<u>1</u>10" -> "<u>0</u>10" with the 2<sup>nd</sup> operation since the 1<sup>st</sup> bit is 1 and 0<sup>th</sup> through 0<sup>th</sup> bits are 0. |
| 28 | +"01<u>0</u>" -> "01<u>1</u>" with the 1<sup>st</sup> operation. |
| 29 | +"0<u>1</u>1" -> "0<u>0</u>1" with the 2<sup>nd</sup> operation since the 0<sup>th</sup> bit is 1. |
| 30 | +"00<u>1</u>" -> "00<u>0</u>" with the 1<sup>st</sup> operation. |
29 | 31 | </pre> |
30 | 32 |
|
31 | 33 | <p> </p> |
|
34 | 36 | <ul> |
35 | 37 | <li><code>0 <= n <= 10<sup>9</sup></code></li> |
36 | 38 | </ul> |
37 | | -</div> |
|
0 commit comments