Just Using Ceil Function


#1

string Solution::convertToTitle(int n) {
string s;

while(n!=0){
int a = n%26;
int b = ceil(n/26);
// cout<<b<<" “;
char c = ‘A’+a-1;
//cout<<c<<” ";
if(c == ‘@’){
b–;
s.push_back(‘Z’);
}
else
s.push_back©;
n = b;
}
reverse(s.begin(),s.end());
return s;

}