168. Excel Sheet Column Title Posted on 2021-02-07 In LeetCode Disqus: Symbols count in article: 395 Reading time ≈ 1 mins. O(n) 1234567891011class Solution {public: string convertToTitle(int n) { string res; while (n) { res += 'A' + (--n) % 26; n /= 26; } return string(rbegin(res), rend(res)); }}; 复杂度不是O(n) 1234567891011class Solution {public: string convertToTitle(int n) { string res; while (n) { res = char('A' + (--n) % 26) + res; // 这里一定要--n不能n-1,反例26 --> Z不是AZ n /= 26; } return res; }};