Simple Java Solution with O(n) time complexity.
Bullets boints to make this question super easily\n\n Construct a string which contains all the alphabet from a to z and also a integer array of length 26.\n co
Bullets boints to make this question super easily\n\n* Construct a string which contains all the alphabet from a to z and also a integer array of length 26.\n* count repeatation of each character and stored in integer arrat.\n* Now loop over integer array in reverse order and apply following codition.\n* if repeated char is less then equal to repeatLimit then directly add it in to answer string,\n* else first add character to answer at most repeatLimit and then loop over them till that character value becomes zero.\n```class Solution {\n    public String repeatLimitedString(String s, int repeatLimit) {\n        String alphabet = "abcdefghijklmnopqrstuvwxyz";\n        int []arr = new int[26];\n        StringBuilder str = new StringBuilder();\n        for(int i=0;i<s.length();i++){\n            arr[s.charAt(i)-\'a\']++;\n        }\n        for(int i=arr.length-1;i>=0;i--){\n            if(arr[i]<=repeatLimit){\n                String a = Character.toString(alphabet.charAt(i));\n                str.append(a.repeat(arr[i]));\n            }else{\n                String a = Character.toString(alphabet.charAt(i));\n                str.append(a.repeat(repeatLimit));\n                arr[i]-=repeatLimit;\n                int j = i-1;\n                while(arr[i]>0&&j>=0){\n                    if(arr[j]>0){\n                        str.append(alphabet.charAt(j));\n                        arr[j]--;\n                        str.append(a.repeat(Math.min(repeatLimit, arr[i])));\n                        arr[i]-=Math.min(repeatLimit, arr[i]);\n                    }\n                    if(arr[j]==0)\n                        j--;\n                }\n                i=j+1;\n            }\n        }\n        return str.toString();\n    }\n}\n```
['Java']