8ms written in c++


  • 0
    S
    int titleToNumber(string s) {
            int length = s.length();
            int sum = 0;
            for(int i=0;i<length;i++){
                int tmp = int(s[i]) - 64;
                for(int j=0;j<(length-i-1);j++){
                    tmp *= 26;
                }
                sum += tmp;
            }
            return sum;
        }

Log in to reply
 

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