[C++] Simple C++ Code || No Priority Queue || 87% time || 85% space
If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.\n\nclass Solution {\npublic:\n
# **If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.**\n```\nclass Solution {\npublic:\n    string repeatLimitedString(string s, int repeatLimit) {\n        vector<int> alphabet(26,0);\n        int f = 0, n = s.size();\n        string ans = "";\n        for(char &ch : s){\n            alphabet[ch-\'a\']++;\n            //sum++;\n        }\n        while(f < n)\n        {\n            int x;\n            for(int i = 25; i >= 0; i--)\n            {\n                if(!alphabet[i]) continue;\n                x = i;\n                break;\n            }\n            int mx = min(repeatLimit, alphabet[x]);\n            for(int j = 0; j < mx; j++){\n                ans += (\'a\'+ x);\n                alphabet[x]--;\n                f++;\n            }\n            if(alphabet[x] == 0 || f == n) continue;\n            int y = x;\n            for(int i = x-1; i >= 0; i--)\n            {\n                if(!alphabet[i]) continue;\n                x = i;\n                break;\n            }\n            if(y == x) return ans;\n            ans += (\'a\' + x);\n            alphabet[x]--;\n            f++;\n        }\n        return ans;\n    }\n};\n```
['C', 'C++']