The idea is to represent any positive integer `n = sum_i a[i]*26^i`

, where `i >= 0`

and `a[i] in [1, 26]`

. Then convert `a[i]`

to char `'A' + a[i] - 1`

and build the string backward.

```
string convertToTitle(int n) {
string res;
while (n > 0) { res += 'A' + (n-1)%26; n = (n - 1)/26; }
reverse(res.begin(), res.end());
return res;
}
```