```
public class Solution {
public int reverse(int x) {
int sign = 1;
if (x < 0){
sign = -1;
x = -x;
}
int ret = 0;
while (x > 0){
if (ret > 214748364)
return 0;
ret = ret*10 + x % 10;
x /= 10;
}
return sign*ret;
}
}
```

if ret == 214748364

x /= 10 can only be 0 or 1

There's no overflow