Simple C++ Solution


  • 0
    J
    class Solution {
    public:
        int titleToNumber(string s) {
            int sum = 0;
            int len = s.length();
            for(int i = 0; i < len; i++)
                sum += ((s[i] - 64) * pow(26, len - i -1)); 
            return sum;
        }
    };
    

Log in to reply
 

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