My C solution


  • 0
    int titleToNumber(char* s) {
        int cnt = 0;
        int sum = 0;
        int i;
        while(s[cnt] != '\0'){
            cnt++;
        }
    
        for(i = 0;i < cnt ; i++){
            sum = sum + pow(26,cnt-i-1)*(s[i]-64);
        }
        return sum;
    }

Log in to reply
 

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