Simple JAVA Solution
\nclass Solution {\n    public String repeatLimitedString(String s, int repeatLimit) {\n        int i = 25, dp[] = new int[26];\n        for (char c: s.toCharAr
```\nclass Solution {\n    public String repeatLimitedString(String s, int repeatLimit) {\n        int i = 25, dp[] = new int[26];\n        for (char c: s.toCharArray()) dp[c - \'a\']++;\n        StringBuilder sb = new StringBuilder();\n        while(i > -1) {\n            while (dp[i] > 0) {\n                int number = Math.min(dp[i], repeatLimit);\n                for (int j = 0; j < number; j++) sb.append((char)(i + \'a\'));\n                dp[i] -= number;\n                if (dp[i] > 0) {\n                    char c = getPrevChar(dp , i-1);\n                    if (c == \'$\') break;\n                    else if (c != \'$\') sb.append(c);\n                }\n            }\n            i--;\n        }\n        return sb.toString();\n    }\n\n    private char getPrevChar(int[] dp,int i) {\n        if (i < 0) return \'$\';\n        if (dp[i] == 0) return getPrevChar(dp, i - 1);\n        else {\n            dp[i]--;\n            return (char)(\'a\' + i);\n        }\n    }\n}\n```
[]