Created
March 6, 2018 14:23
-
-
Save s4553711/3ecd14d628c3a7daf5c0037ed95c350a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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