```
class Solution {
public:
int reverse(int x) {
vector<int> myvector;
int y = (x > 0) ? (x) : (-x);
for( ; y > 0; y = y / 10) myvector.push_back(y % 10);
for(y = 0; !myvector.empty(); myvector.erase(myvector.begin())){
if((y * 10 / 10 != y)) return 0;
y = y * 10 + myvector[0];
}
return (x > 0) ? (y) : (-y);
}
};
```