class Solution {
public:
int titleToNumber(string columnTitle) {
int sum = 0;
for(int i = 0;i<columnTitle.size();i++)
{
int num = columnTitle[i] - 'A' + 1;
sum = sum * 26 + num;
}
return sum;
}
};
class Solution {
public:
string convertToTitle(int columnNumber) {
string s = "";
int a = 0;
int b = 0;
while(columnNumber)
{
a = (columnNumber-1) % 26 + 1;
s += a-1+'A';
columnNumber = (columnNumber-a)/26;
}
reverse(s.begin(),s.end());
return s;
}
};