Easy C solution 3ms


  • 0
    int titleToNumber(char* s) {
        int len = strlen(s);
        int result = 0;
        for(int i=0; i<len; i++){
            int tmp = (s[i]-'A'+1);
            for(int j=0; j<len-i-1; j++){
                tmp = tmp * 26;
            }
            result += tmp;
        }
        return result;
    }
    

Log in to reply
 

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