


(1) Do not use data types with the capacity of more than 32-bit like ‘long int’ or ‘long long int’ in C++. The problem is meant to reverse the integer using a 32-bit data type only.
(2) You should assume that the environment does not allow storing signed or unsigned 64-bit integers.
The first line of input contains an integer 'T' representing the number of test cases.
The first and the only line of each test case contains a 32-bit signed integer ‘N’ representing the integer to be reversed.
For each test case, return the reverse of integer, ’N’.
The output of each test case will be printed in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 5
-2^31 <= N <= 2^31 - 1
Time limit: 1 sec
The idea is to use the fact that the input ‘N’ is a 32 bit signed integer. So, as mentioned, -2147483648 <= ‘N’ <= 2147483647. In this range, for ‘N’ = 10 * x + y, the ‘N’ can never attain a value when |x| = INT_MAX / 10, y = 8 or 9 for x > 0 and y = -9, for x < 0.
Therefore, it is sufficient to check |x| > INT_MAX / 10 (i.e. x > INT_MAX / 10 or x < INT_MIN / 10) for overflow.
The steps are as follows: