#C7428. Reverse Integer with 32-bit Overflow Check
Reverse Integer with 32-bit Overflow Check
Reverse Integer with 32-bit Overflow Check
You are given a 32-bit signed integer n
. Your task is to reverse the digits of the integer. If the reversed integer overflows the 32-bit signed integer range \( [-2^{31}, 2^{31}-1] \), then output 0.
For example, if n = 123
, the reverse is 321
, and if n = -456
, the reverse is -654
. Remember to take care of potential overflow after reversing.
inputFormat
The input consists of a single integer n
provided via standard input (stdin).
outputFormat
Output the reversed integer on standard output (stdout). If the reversed integer overflows the 32-bit signed integer range \( [-2^{31}, 2^{31}-1] \), print 0.
## sample123
321