class Solution {
public:
int reverse(int x) {
int res = 0,temp = 0;
while(x != 0){
if(res < INT_MIN / 10 || res > INT_MAX / 10)return 0;
res = res * 10;
temp = x % 10;
res += temp;
x = x / 10;
}
return res;
}
};
leetcode7
最新推荐文章于 2024-08-31 15:48:32 发布