ByteByteGo logo
menuProblems List

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-2^{31}, 23112^{31} - 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

You can practice coding exercises online by logging into bytebytego.com on your laptop.