A 4ms C solution


  • 9
    G
    int titleToNumber(char* s) {
        int number = 0;
        for (int i = 0; s[i] != 0; i++) {
            number = number*26 + s[i] - 'A' + 1;
        }
        return number;
    }
    

    The question can be rephrased as "Convert base 26 to base 10".


Log in to reply
 

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