Skip to content

Commit 8c439a4

Browse files
committed
Issue #4 solved
1 parent fe2bb8e commit 8c439a4

File tree

2 files changed

+21
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)