import java.util.*;
public class Solution {
/**
*
* @param x int整型
* @return int整型
*/
public int reverse (int x) {
// write code here
if(x>0){
String s1=Integer.toUnsignedString(x);
s1=new StringBuffer(s1).reverse().toString();
int res=Integer.parseInt(s1);
if(res>Math.pow(2,31)-1){
return 0;
}else{
return res;
}
}
if(x<0){
x=-x;
String s1=Integer.toUnsignedString(x);
s1=new StringBuffer(s1).reverse().toString();
int res=Integer.parseInt(s1);
if(res>Math.pow(2,31)){
return 0;
}else{
return -res;
}
}
return 0;
}
}