3085. Minimum Deletions to Make String K-Special
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int minimumDeletions(String word, int k) {\n\n        int res = Integer.MAX_VALUE;\n        int[] freq = new int[26];\n        int sumsofar = 0;\n        for(char ch : word.toCharArray()){\n            freq[ch - \'a\']++;\n        }\n\n        Arrays.sort(freq);\n        for(int i=0;i<26;i++){\n            int temp = sumsofar;\n            for(int j=i+1;j<26;j++){\n                temp += Math.max(0,freq[j]-freq[i]-k);\n            }\n            res = Math.min(res,temp);\n            sumsofar += freq[i];\n        }\n\n        return res;\n        \n    }\n}\n```
['Java']