0168.cpp (296B)
1 class Solution { 2 public: 3 string convertToTitle(int columnNumber) { 4 string res = ""; 5 do { 6 columnNumber -= 1; 7 res += 'A' + columnNumber % 26; 8 } while ((columnNumber /= 26)); 9 reverse(res.begin(), res.end()); 10 return res; 11 } 12 };