Skip to content

Commit 0238bdb

Browse files
committed
Time: 5 ms (19.58%) | Memory: 8.6 MB (21.26%) - LeetSync
1 parent ddf96bf commit 0238bdb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

7-reverse-integer/reverse-integer.cpp

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

0 commit comments

Comments
 (0)