Simple C++ solution


  • 0
    G
        string convertToTitle(int n) {
            string r("");
            do {
                n -= 1;
                string s(1, 'A' + n % 26);
                r = s + r;
                n /= 26;
            } while (n != 0);
            return r;
        }
    

Log in to reply
 

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