java easy solution || 8ms || construct string
class Solution {\n    public String repeatLimitedString(String s, int repeatLimit) {\n        int[] freq = new int[26];\n        for (char ch : s.toCharArray())
class Solution {\n    public String repeatLimitedString(String s, int repeatLimit) {\n        int[] freq = new int[26];\n        for (char ch : s.toCharArray()) {\n            freq[ch - \'a\']++;\n        }\n\n        StringBuilder result = new StringBuilder();\n        int currentCharIndex = 25;\n\n        while (currentCharIndex >= 0) {\n            if (freq[currentCharIndex] == 0) {\n                currentCharIndex--;\n                continue;\n            }\n\n            int use = Math.min(freq[currentCharIndex], repeatLimit);\n            for (int k = 0; k < use; k++) {\n                result.append((char) (\'a\' + currentCharIndex));\n            }\n            freq[currentCharIndex] -= use;\n\n            if (freq[currentCharIndex] > 0) {\n                int smallerCharIndex = currentCharIndex - 1;\n                while (smallerCharIndex >= 0 && freq[smallerCharIndex] == 0) {\n                    smallerCharIndex--;\n                }\n                if (smallerCharIndex < 0) {\n                    break; \n                }\n                result.append((char) (\'a\' + smallerCharIndex));\n                freq[smallerCharIndex]--;\n            }\n        }\n\n        return result.toString();\n    }\n}\n
['Java']