Skip to content

Commit 6efde42

Browse files
committed
Create README - LeetHub
1 parent 80ba2fa commit 6efde42

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

0476-number-complement/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<h2><a href="https://leetcode.com/problems/number-complement/">476. Number Complement</a></h2><h3>Easy</h3><hr><div><p>The <strong>complement</strong> of an integer is the integer you get when you flip all the <code>0</code>'s to <code>1</code>'s and all the <code>1</code>'s to <code>0</code>'s in its binary representation.</p>
2+
3+
<ul>
4+
<li>For example, The integer <code>5</code> is <code>"101"</code> in binary and its <strong>complement</strong> is <code>"010"</code> which is the integer <code>2</code>.</li>
5+
</ul>
6+
7+
<p>Given an integer <code>num</code>, return <em>its complement</em>.</p>
8+
9+
<p>&nbsp;</p>
10+
<p><strong class="example">Example 1:</strong></p>
11+
12+
<pre><strong>Input:</strong> num = 5
13+
<strong>Output:</strong> 2
14+
<strong>Explanation:</strong> The binary representation of 5 is 101 (no leading zero bits), and its complement is 010. So you need to output 2.
15+
</pre>
16+
17+
<p><strong class="example">Example 2:</strong></p>
18+
19+
<pre><strong>Input:</strong> num = 1
20+
<strong>Output:</strong> 0
21+
<strong>Explanation:</strong> The binary representation of 1 is 1 (no leading zero bits), and its complement is 0. So you need to output 0.
22+
</pre>
23+
24+
<p>&nbsp;</p>
25+
<p><strong>Constraints:</strong></p>
26+
27+
<ul>
28+
<li><code>1 &lt;= num &lt; 2<sup>31</sup></code></li>
29+
</ul>
30+
31+
<p>&nbsp;</p>
32+
<p><strong>Note:</strong> This question is the same as 1009: <a href="https://leetcode.com/problems/complement-of-base-10-integer/" target="_blank">https://leetcode.com/problems/complement-of-base-10-integer/</a></p>
33+
</div>

0 commit comments

Comments
 (0)