💥💥✅ Simple Implementation using Priority Queue || T.C = O(N) || Clean Code
\nclass Solution {\npublic:\n    string repeatLimitedString(string s, int repeatLimit) {\n        int freq[26] = {0};\n        string ans = "";\n\t\t\n        f
```\nclass Solution {\npublic:\n    string repeatLimitedString(string s, int repeatLimit) {\n        int freq[26] = {0};\n        string ans = "";\n\t\t\n        for(auto c : s){\n            freq[c-\'a\']++;\n        }\n        \n        priority_queue<pair<char,int>>pq;\n        \n        for(int i=0;i<26;i++){\n            if(freq[i] > 0){\n                pq.emplace((i+\'a\'),freq[i]);\n            }\n        }\n        \n        while(!pq.empty()){\n            \n            auto [key,val] = pq.top();\n            pq.pop();\n            int count = val;\n            \n            for(int i=0;i<repeatLimit && count > 0 ; i++){\n                ans += key;\n                count--;\n            }\n            \n            if(count > 0 && pq.size() > 0){\n                auto [secondKey , secondVal] = pq.top();\n                pq.pop();\n                \n                ans += secondKey;\n                if(secondVal > 1){\n                    pq.emplace(secondKey,secondVal-1);\n                }\n                pq.emplace(key,count);\n            }      \n        }    \n        return ans;\n    }\n};\n\n```
['C', 'Heap (Priority Queue)']