You are given a 32-bit signed integer x. Write its digits in the opposite order and return the new number. Keep the sign as it is.
If the new number does not fit in the 32-bit signed range [-2^31, 2^31 - 1], return 0 instead.
Pretend that your computer cannot store 64-bit integers.
Examples
Example 1:
Input: x = 4560
Output: 654
Explanation: The reversed digits are 0654, which is 654.
Example 2:
Input: x = -908
Output: -809
Explanation: The sign stays, and the digits are reversed.
Example 3:
Input: x = 1230000009
Output: 0
Explanation: The reversed number 9000000321 is bigger than 2^31 - 1, so the answer is 0.