7. Reverse Integer
Practice Reverse Integer for free on NudgeCode: Medium, Bit Manipulation pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Reverse the decimal digits of the signed 32-bit integer x, keeping its sign. If the reversed value falls outside the signed 32-bit range [-2^31, 2^31 - 1], return 0.
Example
x = 123 -> 321
x = -120 -> -21
x = 1534236469 -> 0 (9646324351 is too big)
Constraints
- -2^31 <= x <= 2^31 - 1