Beats 100% -----> Simple Approach
Intuition\nThe problem involves reducing character frequencies to a manageable level by performing deletions. The goal is to minimize the number of deletions re
# Intuition\nThe problem involves reducing character frequencies to a manageable level by performing deletions. The goal is to minimize the number of deletions required to ensure that the difference between the frequencies of any two characters does not exceed a given threshold `k`.\n\n# Approach\n1. **Count Frequencies**: First, count the frequency of each character in the given string.\n2. **Sort Frequencies**: Store these frequencies in a vector and sort them to process from the smallest to largest.\n3. **Minimize Deletions**: For each frequency, attempt to reduce the difference between it and the larger frequencies in the vector. Count the deletions needed to ensure the difference between any two frequencies is at most `k`.\n4. **Track Minimum Deletions**: Accumulate deletions and track the minimum number of deletions needed across all attempts.\n\n# Complexity\n- **Time complexity**: Sorting the frequencies dominates the complexity, so it will be \\(O(n \\log n)\\), where \\(n\\) is the number of unique characters in the string.\n- **Space complexity**: \\(O(n)\\), where \\(n\\) is the number of unique characters in the string due to the frequency map and vector.\n\n# Code\n```cpp\nclass Solution {\npublic:\n    int minimumDeletions(string word, int k) {\n        unordered_map<char, int> mp;\n        for (auto i : word) mp[i]++;\n        \n        vector<int> v;\n        for (auto i : mp) v.push_back(i.second);\n        sort(v.begin(), v.end());\n\n        int ans = INT_MAX;\n        int a = 0;\n\n        for (int i = 0; i < v.size(); i++) {\n            int b = 0;\n            for (int j = i + 1; j < v.size(); j++) {  \n                if (v[j] - v[i] > k) b += v[j] - v[i] - k;\n            }\n            ans = min(ans, b + a);\n            a += v[i];\n        }\n        ans = min(ans, a); \n        return ans;\n    }\n};\n```\n
['C++']