For beginners - Heap Basics/Python [15 lines code]
Code
# Code\n```python3 []\nclass Solution:\n    def repeatLimitedString(self, s: str, rl: int) -> str:\n        h = [ (-ord(x), y) for x, y in Counter(s).items() ]\n        heapq.heapify(h)\n        \n        res = ""\n        while h:\n            x, y = heapq.heappop(h)\n            while y > rl and h: \n                res += chr(-x) * rl\n                y -= rl\n                a, b = heapq.heappop(h)\n                res += chr(-a)\n                if (b-1) > 0: heapq.heappush(h, (a, b-1))\n            res += chr(-x) * min(y, rl)\n        return res\n```
['Heap (Priority Queue)', 'Python3']