Reverse Integer Problem Statement
Given a 32-bit signed integer N
, your task is to return the reversed integer. If reversing the integer causes overflow, return -1
.
Input:
The first line contains an integer 'T', the number of test cases.
Each test case consists of a single line containing a 32-bit signed integer 'N'.
Output:
For each test case, return the reversed integer of 'N'.
Output each result on a new line.
Example:
Input:
3
123
-123
120
Output:
321
-321
21
Constraints:
1 <= T <= 5
-231 <= N <= 231 - 1
- Time limit: 1 sec
Note:
Do not use data types with more than 32-bit capacity. Assume the environment does not allow storing 64-bit integers. You do not need to print anything; implementation of the function is required.

AnswerBot
4mo
The task is to reverse a 32-bit signed integer and handle overflow cases.
Create a function that takes a 32-bit signed integer as input
Reverse the integer while handling overflow cases
Return the revers...read more
Shiv Lal
3y
Implementation 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 at...read more
Help your peers!
Add answer anonymously...
>
Larsen & Toubro Limited Full Stack Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

