Reverse Integer
MediumMath
Given a signed 32-bit integer x, return x with its digits reversed. If reversing causes overflow beyond the 32-bit signed integer range [-2^31, 2^31 - 1], return 0.
Example:
Input: x = 123
Output: 321
Input: x = -123
Output: -321
Constraints:
- •
-2^31 <= x <= 2^31 - 1
Reverse Integer
MediumMath
Given a signed 32-bit integer x, return x with its digits reversed. If reversing causes overflow beyond the 32-bit signed integer range [-2^31, 2^31 - 1], return 0.
Example:
Input: x = 123
Output: 321
Input: x = -123
Output: -321
Constraints:
- •
-2^31 <= x <= 2^31 - 1
Press Run or Ctrl+Enter to execute