C++ || EASY || Hashing || beginner friendly
\n\n# Code\n\nclass Solution {\npublic:\n    int minimumDeletions(string word, int k) {\n        // Count the frequencies of characters in the word\n        vec
\n\n# Code\n```\nclass Solution {\npublic:\n    int minimumDeletions(string word, int k) {\n        // Count the frequencies of characters in the word\n        vector<int> freq(26, 0);\n        for (char c : word) {\n            freq[c - \'a\']++;\n        }\n        \n        // Extract the frequencies and sort them in descending order\n        sort(freq.begin(), freq.end(), greater<int>());\n        \n        // Initialize variables for the minimum deletions and the target frequency list\n        int min_deletions = INT_MAX;\n        \n        // Iterate over the possible target frequencies\n        for (int i = 0; i < freq.size(); ++i) {\n            int target = freq[i];\n            int deletions = 0;\n            // For each target, compute the deletions needed for all other frequencies\n            for (int j = 0; j < freq.size(); ++j) {\n                if (freq[j] > target + k) {\n                    deletions += freq[j] - (target + k);\n                } else if (freq[j] < target) {\n                    deletions += freq[j];\n                }\n            }\n            // Keep track of the minimum deletions found so far\n            min_deletions = min(min_deletions, deletions);\n            \n            if (min_deletions == 0) {  // Early exit if no deletions needed\n                break;\n            }\n        }\n        \n        return min_deletions != INT_MAX ? min_deletions : 0;\n    }\n};\n```
['Hash Table', 'Hash Function', 'C++']