Using hashmap Step wise commented code
# Code\n```cpp []\nclass Solution {\npublic:\n    int minimumDeletions(string word, int k) {\n        // Step 1: Count the frequency of each character in the word\n        unordered_map<char, int> mpp;\n        for (char c : word) mpp[c]++;  // Iterate through the word and increment the count of each character\n\n        // Step 2: Store the frequencies of the characters in a vector\n        vector<int> nums;\n        for (auto &[_, count] : mpp) nums.push_back(count);  // Push the frequency count of each character into the vector\n\n        // Step 3: Sort the frequencies in non-decreasing order\n        sort(nums.begin(), nums.end());  // Sorting the frequencies helps in calculating deletions efficiently\n\n        // Step 4: Initialize variables\n        int n = nums.size(), mini = INT_MAX;  // \'n\' is the number of unique characters, \'mini\' stores the minimum deletions\n\n        // Step 5: Iterate through all possible ways of dividing the frequencies\n        for (int i = 0; i < n; i++) {  // Try different indices to split the frequencies\n            int deleted = 0;  // This will hold the number of deletions required for this particular split\n            \n            // Step 6: Handle characters with frequency less than or equal to the chosen frequency\n            for (int j = 0; j < i; j++)  // For characters with frequency less than or equal to nums[i]\n                deleted += nums[j];  // We need to delete all of them\n            \n            // Step 7: Handle characters with frequency greater than nums[i]\n            for (int j = i; j < n; j++)  // For characters with frequency greater than nums[i]\n                if (nums[j] - nums[i] > k)  // If the difference between the frequency and nums[i] is greater than k\n                    deleted += (nums[j] - (nums[i] + k));  // We delete the excess characters beyond nums[i] + k\n            \n            // Step 8: Update the minimum deletions\n            mini = min(mini, deleted);  // Track the minimum deletions required\n        }\n\n        // Step 9: Return the result\n        return mini;  // Return the minimum number of deletions\n    }\n};\n\n\n```
['C++']