num that fits in a signed 32-bit integer. Write its digits in reverse order, keep the sign, and return the result.
If the reversed number falls outside [-2³¹, 2³¹ − 1], return 0.
Assume you cannot store 64-bit numbers: catch the overflow before it happens.num=4071 → 1704
Digits 4, 0, 7, 1 read backwards give 1704.
num=-560 → -65
The sign stays, and the trailing zero becomes a leading one and disappears: -65.
num=1999999999 → 0
Reversed it is 9999999991, which exceeds 2³¹ − 1, so the answer is 0.
num=4071
1704
Run checks the first 3 tests in your browser. Submit checks all 54 tests on the server, hidden ones included.