mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-13 01:15:14 +08:00
update
This commit is contained in:
@@ -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> 中,输入表示有符号整数 <code>-3</code>,输出表示有符号整数 <code>-1073741825</code>。</li>
|
||||
</ul>
|
||||
<p>颠倒给定的 32 位有符号整数的二进制位。</p>
|
||||
|
||||
<p> </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,
|
||||
因此返回 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> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li>输入是一个长度为 <code>32</code> 的二进制字符串</li>
|
||||
<li><code>0 <= n <= 2<sup>31</sup> - 2</code></li>
|
||||
<li><code>n</code> 为偶数</li>
|
||||
</ul>
|
||||
|
||||
<p> </p>
|
||||
|
Reference in New Issue
Block a user