clueless coding // TODO: be smarter

LeetCode Excel Sheet Column Number: Java Solution



TL;DR Code Solution


public int titleToNumber(String s) {

    int result = 0;

    for (int i = 0; i < s.length(); i++) {

        result *= 26;
        char cur = s.charAt(i);
        result += cur - 'A' + 1;



    }

    return result;

}