|
| 1 | +<h2><ahref="https://leetcode.com/problems/reverse-integer/">7. Reverse Integer</a></h2><h3>Medium</h3><hr><p>Given a signed 32-bit integer <code>x</code>, return <code>x</code><em> with its digits reversed</em>. If reversing <code>x</code> causes the value to go outside the signed 32-bit integer range <code>[-2<sup>31</sup>, 2<sup>31</sup> - 1]</code>, then return <code>0</code>.</p> |
| 2 | + |
| 3 | +<p><strong>Assume the environment does not allow you to store 64-bit integers (signed or unsigned).</strong></p> |
| 4 | + |
| 5 | +<p> </p> |
| 6 | +<p><strongclass="example">Example 1:</strong></p> |
| 7 | + |
| 8 | +<pre> |
| 9 | +<strong>Input:</strong> x = 123 |
| 10 | +<strong>Output:</strong> 321 |
| 11 | +</pre> |
| 12 | + |
| 13 | +<p><strongclass="example">Example 2:</strong></p> |
| 14 | + |
| 15 | +<pre> |
| 16 | +<strong>Input:</strong> x = -123 |
| 17 | +<strong>Output:</strong> -321 |
| 18 | +</pre> |
| 19 | + |
| 20 | +<p><strongclass="example">Example 3:</strong></p> |
| 21 | + |
| 22 | +<pre> |
| 23 | +<strong>Input:</strong> x = 120 |
| 24 | +<strong>Output:</strong> 21 |
| 25 | +</pre> |
| 26 | + |
| 27 | +<p> </p> |
| 28 | +<p><strong>Constraints:</strong></p> |
| 29 | + |
| 30 | +<ul> |
| 31 | +<li><code>-2<sup>31</sup> <= x <= 2<sup>31</sup> - 1</code></li> |
| 32 | +</ul> |