dsa · easy
Reverse Integer
GreyOrangeMathFoundation
Given a signed 32-bit integer x, return x with its digits reversed. If reversing causes overflow outside [-2^31, 2^31-1], return 0.
Arguments
x— the input integer
**Example:** x = 123 → 321. x = -123 → -321.
Constraints
-2^31 <= x <= 2^31 - 1
Examples
Example 1
Input: 123 Expected: 321
Example 2
Input: -123 Expected: -321