My simple simple solution


  • 0
    J
    class Solution {
    public:
        int atoi(const char *str) {
            if(*str == '\0') return 0;
            string s(str);
            istringstream iss(s);
            int n;
            iss>>n;
            return n;
        }
    };
    

    istringstream is a very powerful tool in C++.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.