My simple c++ solution


  • 1
    K
    class Solution {
    public:
    string convertToTitle(int n) {
        string res="";
        while(n>0){
            int num=n%26 -1;
            char t= (num >=0)? num+'A' :'Z';
            res=t+res;
            n=(n-1)/26;
        }
        return res;
    }
    

    };


Log in to reply
 

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