Problem
You get a signed 32-bit integer x. A signed 32-bit integer is a whole number from -2^31 to 2^31 - 1.
Reverse the order of the digits of x, and keep the sign of x. Zeros at the end of x disappear, because they move to the start of the result.
If the result is outside the signed 32-bit range, return 0. Assume that your environment cannot store 64-bit integers.
Example 1
- Input:
- x = 482
- Output:
- 284
Example 2
- Input:
- x = -905
- Output:
- -509
- Explanation:
- The sign stays, and the digits 905 become 509.
Example 3
- Input:
- x = 2000000009
- Output:
- 0
- Explanation:
- The reversed value 9000000002 is larger than
2^31 - 1, so the answer is 0.
Constraints
- -2^31 <= x <= 2^31 - 1
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Evaluate Reverse Polish Notation
Coding · Array · Math · Stack
- Integer to English Words
Coding · Math · Recursion · String
- Roman to Integer
Coding · Hash Table · Math · String
- Add Binary
Coding · Bit Manipulation · Math · Simulation
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 2 records
eBay
Leetcode 7. Reverse Integer
Reported May 28, 2026 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceOracle
Leetcode 7. Reverse Integer
Reported Apr 24, 2025 · 1 source report
STAFF
Source snapshot: Nov 12, 2026
View source
LeetCode company tags · 7 records
Bloomberg
Reverse Integer
Reported date not specified · Source window: 3mo
Source snapshot: Oct 20, 2026
Source frequency score: 61.8. This is not an interview probability.
View sourceGoogle
Reverse Integer
Reported date not specified · Source window: 30d