Reverse Integer
Medium · Math & Number Theory · about 15 minutes
Asked at Google, Meta, Bloomberg, Apple, Amazon, Microsoft, Jane Street, Rivian, Sony.
Reverse the order of the decimal digits of the signed 32-bit integer x, keeping its sign. If the result doesn't fit in the signed 32-bit range [-2³¹, 2³¹ − 1], return 0 instead. Pretend 64-bit integers are not available.