1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-13 01:15:14 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2025-09-29 14:43:44 +08:00
parent 2862a227c4
commit 13f2098086
4409 changed files with 168933 additions and 166256 deletions

View File

@@ -1,36 +1,68 @@
<p>颠倒给定的 32 位符号整数的二进制位。</p>
<p><strong>提示:</strong></p>
<ul>
<li>请注意,在某些语言(如 Java没有无符号整数类型。在这种情况下输入和输出都将被指定为有符号整数类型并且不应影响您的实现因为无论整数是有符号的还是无符号的其内部的二进制表示形式都是相同的。</li>
<li>在 Java 中,编译器使用<a href="https://baike.baidu.com/item/二进制补码/5295284" target="_blank">二进制补码</a>记法来表示有符号整数。因此,在 <strong>示例 2</strong>&nbsp;中,输入表示有符号整数 <code>-3</code>,输出表示有符号整数 <code>-1073741825</code></li>
</ul>
<p>颠倒给定的 32 位符号整数的二进制位。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<p><strong class="example">示例 1</strong></p>
<pre>
<strong>输入:</strong>n = 00000010100101000001111010011100
<strong>输出:</strong>964176192 (00111001011110000010100101000000)
<strong>解释:</strong>输入的二进制串 <strong>00000010100101000001111010011100 </strong>表示无符号整数<strong> 43261596</strong><strong>
</strong> 因此返回 964176192其二进制表示形式为 <strong>00111001011110000010100101000000</strong></pre>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>n = 43261596</span></p>
<p><strong>示例 2</strong></p>
<p><span class="example-io"><b>输出:</b>964176192</span></p>
<pre>
<strong>输入:</strong>n = 11111111111111111111111111111101
<strong>输出:</strong>3221225471 (10111111111111111111111111111111)
<strong>解释:</strong>输入的二进制串 <strong>11111111111111111111111111111101</strong> 表示无符号整数 4294967293
&nbsp; 因此返回 3221225471 其二进制表示形式为 <strong>10111111111111111111111111111111 。</strong></pre>
<p><strong>解释:</strong></p>
<table>
<tbody>
<tr>
<th>整数</th>
<th>二进制</th>
</tr>
<tr>
<td>43261596</td>
<td>00000010100101000001111010011100</td>
</tr>
<tr>
<td>964176192</td>
<td>00111001011110000010100101000000</td>
</tr>
</tbody>
</table>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>n = 2147483644</span></p>
<p><span class="example-io"><b>输出:</b>1073741822</span></p>
<p><strong>解释:</strong></p>
<table>
<tbody>
<tr>
<th>整数</th>
<th>二进制</th>
</tr>
<tr>
<td>2147483644</td>
<td>01111111111111111111111111111100</td>
</tr>
<tr>
<td>1073741822</td>
<td>00111111111111111111111111111110</td>
</tr>
</tbody>
</table>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li>输入是一个长度为 <code>32</code> 的二进制字符串</li>
<li><code>0 &lt;= n &lt;= 2<sup>31</sup>&nbsp;- 2</code></li>
<li><code>n</code>&nbsp;为偶数</li>
</ul>
<p>&nbsp;</p>