Python short solution using heap
\n      \n        \n        The idea is simple, keep a max heap of all the characters and their available counts.\n        If the max character element at the t
\n      \n        \n        The idea is simple, keep a max heap of all the characters and their available counts.\n        If the max character element at the top of the heap is already exceeding the limit interms of count,\n        then pop the next one and add to heap. Also add back the unused max character element to the heap.\n        \n  \n```\ndef repeatLimitedString(self, s: str, limit: int) -> str:\n\theap = [ (-ord(ch), ch, count) for ch, count in Counter(s).items() ]\n\theapify(heap)\n\tres, count = [], 0\n\n\twhile heap:\n\t\tmax_heap_key, ch, rem = heappop(heap)\n\t\tif res and res[-1] == ch and (count+1) > limit:\n\t\t\tif not heap: break\n\t\t\tmax_heap_key2, ch2, rem2 = heappop(heap)\n\t\t\theappush(heap, (max_heap_key, ch, rem))\n\t\t\tmax_heap_key, ch, rem = max_heap_key2, ch2, rem2\n\n\t\tif res and res[-1] != ch:\n\t\t\tcount = 0\n\n\t\tres.append(ch)\n\t\trem -= 1\n\t\tif rem:\n\t\t\theappush(heap, (max_heap_key, ch, rem))\n\t\tcount += 1\n\treturn \'\'.join(res)           \n```\n```\n\t
[]