Coding-Interview-101

Solutions to LeetCode problems filtered with companies, topics and difficulty.

View project on GitHub

Excel Sheet Column Title


Solution


    class Solution {
    public:
        string convertToTitle(int n) {
            string ans = "";
            while(n) {
                char ch = ('A' + (n - 1) % 26);
                ans = ch + ans;
                n = (n - 1) / 26;
            }
            return ans;
        }
    };