My 8ms C++ solution


  • 0
    V
    class Solution {
    public:
        int titleToNumber(string s) {
            int len = s.size(), i = 0, ret= 0;
            if (len == 0) return 0;
            
            for (i = 0; i < len; i++)
                ret = ret * 26 + (toupper(s[i]) - 'A' + 1);
            
            return ret;
        }
    };

Log in to reply
 

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