It's very easy if you use Stringstream in C++


#1

int Solution::atoi(const string A) {
stringstream ss(A);
int number;

ss >> number;

if(number>INT_MAX) return INT_MAX;
if(number<INT_MIN) return INT_MIN;

return number;

}