one loop My c++


  • 0
    L
    class Solution {
    public:
        int titleToNumber(string s) {
            int res = 0;
            for(int i = 0 ; i < s.size() ; ++i){
                res = 26* res +s[i]-'A'+1;
            }
            return res;
        }
    };
    

Log in to reply
 

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