4 line C++ solution


  • 3
    L
    int titleToNumber(string s) {
    
        int len = s.length(), sum=0;
        
        for(int i=0;i<len;i++)
            sum += (int(s[i]-'A'+1))*pow(26,len-1-i);
            
        return sum;
    }

Log in to reply
 

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