A short accepted solution within 8ms (c++)


  • 0
    T
    class Solution {
    public:
        int titleToNumber(string s) {
            int n = s.size();
            int res = 0, index=0;
            while(index<n)
                res+=pow(26,index)*(s[n-1-index++]-'A'+1);
            return res;
        }
    };

Log in to reply
 

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