C++ , 4 line solution


#1

string convertToTitle(int n) {
string ans;
while (n) {
ans = char ((n - 1) % 26 + ‘A’) + ans;
n = (n - 1) / 26;
}
return ans;
}


#3

Cool but it’s 5 lines.