Easy C++ solution


  • 3
    R
    class Solution {
    public:
        string convertToTitle(int n) {
            string str ="";
            while(n>0)
            {
                char letter = 'A'+(n-1)%26;
                str = letter+str;
                n = (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.