#C10819. Reverse Integer
Reverse Integer
Reverse Integer
You are given a 32-bit signed integer n
. Your task is to reverse its digits while preserving its sign. If the reversed integer overflows the 32-bit signed integer range \( [-2^{31}, 2^{31}-1] \), then output 0.
Example: If n = 123
, then the reversed integer is 321
.
If n = -456
, then the reversed integer is -654
.
The input will be read from standard input (stdin) and the result should be printed to standard output (stdout).
inputFormat
The input consists of a single integer \( n \) provided in one line from the standard input.
outputFormat
Output the reversed integer. If the reversed integer is outside the 32-bit signed integer range \( [-2^{31}, 2^{31}-1] \), output 0.
## sample123
321