clueless coding // TODO: be smarter

LeetCode Excel Sheet Column Number: CPP Solution



TL;DR Code Solution


int titleToNumber(string s) {

    int result = 0;
    for (int i = 0; i < s.length(); i++) {
        result *= 26;
        result += s[i] - 'A' + 1;
    }
    return result;

}