class Solution {
public int reverse(int x) {
long result = 0;
while (x != 0) {
result = result * 10 + x % 10;
if (result > Integer.MAX_VALUE || result < Integer.MIN_VALUE) {
return 0;
}
x /= 10;
}
return (int) result;
}
}
LC刷题-7
最新推荐文章于 2022-12-07 10:31:05 发布