C++ Solution || without Heap, using Map
if it's help, please up ⬆ vote! ❤️Complexity
Overall Time Complexity: O(nlogk+26n) = O(nlogk)

Space complexity: O(k) (max 26 char)
Code
# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n\n\n\n## Complexity\n- Overall Time Complexity: **O(nlogk+26n) = O(nlogk)**\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(k) (max 26 char)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    void eraseData(map<char, int> &store, char ch)\n    {\n        if(not store[ch])\n            store.erase(ch);\n    }\n    string repeatLimitedString(string s, int repeatLimit) \n    {\n        map<char, int> store;\n        for(auto ch : s) store[ch] += 1;\n        \n        string ans;\n        int count = 0;\n\n        char prev = \'-\';\n        while(!store.empty())\n        {\n            char ch = store.rbegin()->first;\n\n            if(prev != ch or count < repeatLimit)\n            {\n                ans += ch;\n                store[ch] -= 1;\n                eraseData(store, ch);\n\n                if(prev == ch) count += 1;\n                else count = 1, prev = ch;\n            }\n            else \n            {\n                bool flag = true;\n                for(char nextChar = ch - 1; nextChar >= \'a\'; nextChar--)\n                {\n                    if(store.count(nextChar))\n                    {\n                        ans += nextChar;\n                        store[nextChar] -= 1;\n                        eraseData(store, nextChar);\n                        count = 1, prev = nextChar, flag = false;\n                        break;\n                    }\n                }\n                if(flag) break;\n            }\n        }\n\n        return ans;    \n    }\n};\n```
['Hash Table', 'String', 'Greedy', 'Counting', 'C++']