Skip to content

Instantly share code, notes, and snippets.

@s4553711
Created March 6, 2018 14:23
Show Gist options
  • Save s4553711/3ecd14d628c3a7daf5c0037ed95c350a to your computer and use it in GitHub Desktop.
Save s4553711/3ecd14d628c3a7daf5c0037ed95c350a to your computer and use it in GitHub Desktop.
class Solution {
public:
string convertToTitle(int n) {
string result;
int remain = 0;
while(n > 0) {
remain = (--n) % 26;
result.push_back(remain + 65);
n /= 26;
}
reverse(result.begin(), result.end());
return result;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment