Reverse Integer

Medium
math
Problem Description

Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-2^31, 2^31 - 1], then return 0.

Input Format
A single integer x
Output Format
The reversed integer
Constraints
-2^31 <= x <= 2^31 - 1
Sample Input/Output
Input:
123
Output:
321
Explanation

Reverse the digits of 123 to get 321.

Solution Hints
150
Points
2000ms
Time Limit
256MB
Memory Limit
Code Editor
Register to Submit
Register to Access Code Editor

Create a free account to solve coding problems and track your progress.

Register Now
Feedback