168. Excel Sheet Column Title - cocoder39/coco39_LC GitHub Wiki
1 -> A
2 -> B
3 -> C
...
26 -> Z
27 -> AA
28 -> AB
27 = 1*26 + 1 = A*26 + A => how to make 1 = A
n%26 + A - 1
or n--; n%26 + A
? => test with 26 = Z
string convertToTitle(int n) {
string res;
while (n > 0) {
n--;
res.push_back(n % 26 + 'A');
n /= 26;
}
reverse(res.begin(), res.end());
return res;
}