Well, this problem can be solved in 1-line clearly. Take a look at this link :-)
1 class Solution { 2 public: 3 string convertToTitle(int n) { 4 return !n ? "" : convertToTitle((n - 1) / 26) + char((n - 1) % 26 + 'A'); 5 } 6 };
Well, this problem can be solved in 1-line clearly. Take a look at this link :-)
1 class Solution { 2 public: 3 string convertToTitle(int n) { 4 return !n ? "" : convertToTitle((n - 1) / 26) + char((n - 1) % 26 + 'A'); 5 } 6 };