Reverse 32-Bit Integer
Medium
Reverse the digits of a signed 32-bit integer. If the reversed integer overflows (i.e., is outside the range [−231, 231−1]), return 0. Assume the environment only allows you to store integers within the signed 32-bit integer range.
Example 1:
Input: n = 420
Output: 24
Example 2:
Input: n = -15
Output: -51