1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/整数反转 [reverse-integer].html
2022-03-29 12:43:11 +08:00

43 lines
955 B
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个 32 位的有符号整数 <code>x</code> ,返回将 <code>x</code> 中的数字部分反转后的结果。</p>
<p>如果反转后整数超过 32 位的有符号整数的范围 <code>[2<sup>31</sup>,  2<sup>31 </sup> 1]</code> ,就返回 0。</p>
<strong>假设环境不允许存储 64 位整数(有符号或无符号)。</strong>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>x = 123
<strong>输出:</strong>321
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>x = -123
<strong>输出:</strong>-321
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>x = 120
<strong>输出:</strong>21
</pre>
<p><strong>示例 4</strong></p>
<pre>
<strong>输入:</strong>x = 0
<strong>输出:</strong>0
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>-2<sup>31</sup> <= x <= 2<sup>31</sup> - 1</code></li>
</ul>