An new idea within 1 ms


  • 0
    R
        string convertToTitle(int n) {
            const string albet = "ZABCDEFGHIJKLMNOPQRSTUVWXYZ";
            string ret = "";
            while (n > 0){
                ret = albet[n%26] + ret;
                n = (n - 1)/26;
            }
            return ret;
        }
    

    I learned that in another contest, and that provide me a different perspective to think.
    What a wonderful idea.


Log in to reply
 

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