#7
Reverse Integer
expert · 1170 · lc medium +32 · verified · 31.6% accepted · 15,380 likes · top 9%
Description
Reverse the decimal digits of signed 32-bit integer x. Return 0 if the reversed value falls outside the range [-231, 231 - 1]. Storing 64-bit integers is not permitted.
Example 1:
Input: x = 123
Output: 321
Example 2:
Input: x = -123
Output: -321
Example 3:
Input: x = 120
Output: 21
Code
1
2
3