Home
Topics
Practice
Roadmap
DSA Tracker
Code Editor
Tech Blogs
More
Sign in
Get started
Loading question...
Feedback
Reverse Integer
Medium
00:00
0 users online
Share
Description
Solution
Submissions
Discussion
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.
Sample Input:
123
Sample Output:
321
Hints
Hint 1
Handle negative numbers by storing the sign
Hint 2
Check for overflow before returning
Hint 3
Use modulo and division to reverse digits
Code Editor
Reset
Run
Save
Loading...