题目:力扣https://leetcode-cn.com/problems/reverse-integer/
class Solution {
public int reverse(int x) {
long n = 0;
while(x != 0) {
n = n*10 + x%10;
x = x/10;
}
return (int)n==n? (int)n:0;
}
}
代码作者:力扣
这份代码真的优雅得像诗歌。简洁明了,高效干练。