class Solution {
public int reverse(int x) {
if(x == 0){
return 0;
}
if(x>0 && x< (2<<32 - 1)){
String s = String.valueof(x);
return reverseString(s);
}else if(x<0 &&Math.abs(x)<(2<<31) ){
String s = String.valueof(x);
return Math.round(reverseString(s));
}
}
public Integer reverseString(String s){
char[] chars = s.toCharArray();
String res = "";
for(int i = chars.length - 1;i>=0;i--){
res = chars[i]+res;
}
retrun Integer.parseInt(res);
}
}
报错了 周日加班在看