✅ ⬆️ | Simple Sorting |  Different Methods  | 🔥🔥  [Java]
Approach-1 (Straight forward)\nT.C : O(n)\nS.C : O(1)\n\nclass Solution {\n    public int minimumDeletions(String word, int k) {\n        int[] freq = new int[2
Approach-1 (Straight forward)\nT.C : O(n)\nS.C : O(1)\n```\nclass Solution {\n    public int minimumDeletions(String word, int k) {\n        int[] freq = new int[26];\n\n        for (char ch : word.toCharArray()) {\n            freq[ch - \'a\']++;\n        }\n\n        Arrays.sort(freq);\n\n        int result = word.length();\n        int cumulativeDeleted = 0;\n\n        for (int i = 0; i < 26; i++) {\n            int del = cumulativeDeleted;\n            for (int j = 25; j > i; j--) {\n                if (freq[j] - freq[i] <= k) {\n                    break;\n                }\n\n                del += freq[j] - freq[i] - k;\n            }\n\n            result = Math.min(result, del);\n            cumulativeDeleted += freq[i];\n        }\n\n        return result;\n    }\n}\n```\n\n\nApproach-2 (slight optimisation of above approach)\nT.C : O(n) because other iterations are on a constant sized array\nS.C : O(1) - 26 sized array\n\n```\nclass Solution {\n    public int minimumDeletions(String word, int k) {\n        int[] freq = new int[26];\n\n        for(char ch : word.toCharArray()) {\n            freq[ch-\'a\']++;\n        }\n\n        Arrays.sort(freq);\n\n        int result = Integer.MAX_VALUE;\n        int deletedTillNow = 0;\n\n        for(int i = 0; i < 26; i++) {\n            int minFreq = freq[i];\n            int temp = deletedTillNow; //temp taken to find deletion for j = 25 to j > i\n\n            for(int j = 25; j > i; j--) {\n                if(freq[j] - freq[i] <= k) \n                    break;\n                \n                temp += freq[j] - minFreq - k;\n            }\n\n            result = Math.min(result, temp);\n            deletedTillNow += minFreq;\n        }\n\n        return result;\n    }\n}\n\n```\n\n![image](https://assets.leetcode.com/users/images/d8e70522-744d-42f0-b3a9-82c4c3d9665c_1708866963.8842509.png)\n\n**Please Upvote**\n
['Java']