C++ solution


  • 1
    S
    class Solution {
    public:
        string convertToTitle(int n) {
            string res="";
            while(n!=0){
                n--;
                res=(char)((n)%26 + 'A') + res;
                n/=26;
            }
            return res;
        }
    };
    

Log in to reply
 

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