✅ Simple Java Solution | Map + PQ
CODE\nJava []\npublic String repeatLimitedString(String s, int repeatLimit) {\n\tMap<Character, Integer> map = new HashMap<>();\n\tfor(char ch : s.toCharArray()
## **CODE**\n```Java []\npublic String repeatLimitedString(String s, int repeatLimit) {\n\tMap<Character, Integer> map = new HashMap<>();\n\tfor(char ch : s.toCharArray()){\n\t\tmap.put(ch, map.getOrDefault(ch, 0) + 1);\n\t}\n\n\tPriorityQueue<Character> pq = new PriorityQueue<>(Collections.reverseOrder());\n\tfor(char ch : map.keySet()) pq.add(ch);\n\n\tStringBuffer res = new StringBuffer("");\n\twhile(!pq.isEmpty()) {\n\t\tchar curr = pq.remove();\n\t\tint min = Math.min(map.get(curr), repeatLimit);\n\t\tres.append((""+curr).repeat(min));\n\n\t\tif(map.get(curr) == min) map.remove(curr);\n\t\telse if(!pq.isEmpty()) {\n\t\t\tchar next = pq.remove();\n\t\t\tres.append(next);\n\t\t\tif(map.get(next) == 1) map.remove(next);\n\t\t\telse {\n\t\t\t\tmap.put(next, map.get(next)-1);\n\t\t\t\tpq.add(next);\n\t\t\t}\n\n\t\t\tmap.put(curr, map.get(curr)-min);\n\t\t\tpq.add(curr);\n\t\t}\n\t}\n\treturn res.toString();\n}\n```
['Java']