C++ "One Line" solution based on recursion


  • 0
    W
    class Solution {
    public:
        int titleToNumber(string s) {
            return s.size() == 1?s[0] - 'A' + 1 : titleToNumber(s.substr(0, s.size()-1))*26 + s.back() - 'A' + 1;
        }
    };
    

Log in to reply
 

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