Question:
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
Solution:
用long处理溢出,注意long和int不能相加~
我的笨办法
public class Solution {
public int reverse(int x) {
int count=0;
long tmp=0;
long sum=0;
int num=1;
int cur=x;
whi