Solution using UNORDERED MAP ; C++


#1
string Solution::convertToTitle(int A) {
    unordered_map<int,char> m;
    string s="ABCDEFGHIJKLMNOPQRSTUVWXY";
    for(int i=0;i<26;i++){
        m[i+1] = s[i];
    }
    m[0] = 'Z';
    string ret = "";
    while(A>0){
        ret += m[A%26];
        if(A%26 == 0)
            A-=1;
        A = A/26;
        
    }
    reverse(ret.begin(),ret.end());
    return ret;
}