Skip to content

Commit eb87e6f

Browse files
committed
Time: 2 ms (66.61%), Space: 5.8 MB (95.63%) - LeetHub
1 parent 41955e4 commit eb87e6f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
int reverse(int n) {
4+
long long int ans = 0;
5+
while(n!=0)
6+
{
7+
int digit = n% 10;
8+
if ( (ans > INT_MAX/10) || (ans < INT_MIN/10) )
9+
return 0;
10+
ans = (ans*10)+digit;
11+
n = n/10;
12+
}
13+
14+
return ans;
15+
16+
}
17+
};

0 commit comments

Comments
 (0)