Simple java solution
Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Code\n\nclass Solution {\n    public int minimumDeletions(String word, int k) {\n        in
# Complexity\n- Time complexity: $$O(n)$$\n\n- Space complexity: $$O(1)$$\n\n# Code\n```\nclass Solution {\n    public int minimumDeletions(String word, int k) {\n        int a[]=new int[26];\n        for(char c:word.toCharArray())\n        {\n            a[c-\'a\']++;\n        }\n        Arrays.sort(a);\n        List<Integer> nm = new ArrayList<>();\n        for(int i=25;i>=0;i--)\n        {\n            if(a[i] == 0)\n            {\n                break;\n            }\n            else\n            {\n                nm.add(a[i]);\n            }\n        }\n        int ans = Integer.MAX_VALUE;\n        for(int i=0;i<nm.size();i++)\n        {\n            int data=nm.get(i);\n            int min=0;\n            for(int j:nm)\n            {\n                if(j>(data + k))\n                {\n                    min += j-(data + k);\n                }\n                else if(j<data)\n                {\n                    min += j;\n                }\n            }\n            ans=Math.min(ans, min);\n            if(ans == 0)\n            {\n                break;\n            }\n        }\n        return ans == Integer.MAX_VALUE ? 0 : ans;   \n    }\n}\n```
['Java']