C++ Easy Solution
\n#define deb(x) cout << #x << " = " << x << endl\nclass Solution {\npublic:\n    string repeatLimitedString(string s, int rL) {\n        map<char,int> m ;\n   
```\n#define deb(x) cout << #x << " = " << x << endl\nclass Solution {\npublic:\n    string repeatLimitedString(string s, int rL) {\n        map<char,int> m ;\n        for (int i =0;i<26;i++)m[i+\'a\']=0;\n        for (int i = 0 ;i <s.length();i++)\n            m[s[i]]++;\n        string res = "";\n        priority_queue <pair<int,int>>pq ;\n        for(int i =0 ;i<26;i++) if(m[i+\'a\'])pq.push({i+\'a\',m[i+\'a\']});\n        while(!pq.empty()){\n            char c = pq.top().first;\n            int x = pq.top().second;\n            pq.pop();\n            int leftOvers = x-rL;\n            // deb(c);\n            // deb(x);\n            if(leftOvers<=0){\n                if(res.length()){\n                    if(res[res.length()-1]==c) continue;\n                }\n                while(x){\n                    res+=c;\n                    x--;\n                }\n            }else{\n                while(x!=leftOvers){\n                    res+=c;\n                    x--;\n                }\n                if(pq.empty()) return res;\n                char ctemp = pq.top().first;\n                int xtemp = pq.top().second;\n                pq.pop();\n                res+=ctemp;\n                xtemp--;\n                pq.push({c,leftOvers});\n                if(xtemp) pq.push({ctemp,xtemp});\n            }\n        }\n        return res;\n    }\n};\n```
['Greedy', 'C', 'Heap (Priority Queue)', 'C++']