Four lines' Solution


  • 0
    A
    class Solution {
    public:
        string convertToTitle(int n) {
            string str = "";
            if (n > 26) str = convertToTitle((n-1)/26);
            str += 'A'+(n-1)%26;
            return str;
        }
    };

Log in to reply
 

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