βExcel Column Title
string Solution::convertToTitle(int A) {
string res = "";
while(A) {
int digit = (A - 1) % 26;
A = (A - 1) / 26;
res = (char)(digit + 'A') + res;
}
return res;
}
Get each digit as a number from 0 to 25
Move that many steps ahead from 'A'
Remove that much magnitude
Last updated