[c++] Frequency Vector + Priority Queue
\nclass Solution {\npublic:\n    string repeatLimitedString(string s, int limit){\n        vector<int> hash(26);\n        for(int i=0;i<s.length();i++) hash[s[i
```\nclass Solution {\npublic:\n    string repeatLimitedString(string s, int limit){\n        vector<int> hash(26);\n        for(int i=0;i<s.length();i++) hash[s[i]-\'a\']++;\n        priority_queue<pair<char,int>> pq; \n        for(int i=0;i<26;i++) if(hash[i]) pq.push({\'a\'+i,hash[i]});\n        string res="";\n        while(!pq.empty()){\n            char c=pq.top().first; int freq=pq.top().second; pq.pop();\n            int temp=min(limit,freq);\n            while(temp--) res.push_back(c);\n            if(pq.empty()) return res;\n            freq=freq-min(limit,freq);\n            if(freq){\n                char smol=pq.top().first; int smolfreq=pq.top().second; pq.pop();\n            res.push_back(smol); smolfreq--;\n            if(smolfreq) pq.push({smol,smolfreq});\n                pq.push({c,freq});\n            }\n            \n        }\n        return res;\n    }\n};\n```
['Greedy', 'C', 'Heap (Priority Queue)', 'C++']