[Java/C++/Python] Enumerate Minimum Frequency
Intuition\nFirst, we need to calculate character frequencies.\nwe delete characters for two reasons:\n1. Delete the small frequency to zero, so it doesn\'t coun
# **Intuition**\nFirst, we need to calculate character frequencies.\nwe delete characters for two reasons:\n1. Delete the small frequency to zero, so it doesn\'t count for the rule.\n2. Delete the big frequency smaller, so it `big freq - small freq <= k`.\nAnd we won\'t reduce small freq to smaller positive.\n<br>\n\n# **Intuition 2**\nAfter deletion,\nthe char with the minimum frequency,\nmust not have been deleted,\nit\'s same as its original frequency in `word`.\n<br>\n\n# **Explanation**\n\nEnumerate character\'s frequency `x`\nThe goal is to find the minimum deletions needed,\nif we take it as the minimum frequency after deletion.\n\nThen we iterates over all character frequencies `a`,\nit calculates the deletions required to meet the k-special condition:\nIf `a < x`, all instances of that character need to be deleted.\nIf `a > x + k`, then `a - (x + k)` deletions are needed.\nUpdate this to current result `cur`.\n\nFinally return the minimum result we found.\n<br>\n\n# **Complexity**\nTime `O(n + 26 * 26)`\nSpace `O(26)`\n<br>\n\n**Java**\n```java\n    public int minimumDeletions(String word, int k) {\n        int res = 100000, A[] = new int[26];\n        for (char c : word.toCharArray()) {\n            A[c - \'a\']++;\n        }\n        for (int x : A) {\n            int cur = 0;\n            for (int a : A) {\n                cur += (a < x) ? a : Math.max(0, a - (x + k));\n            }\n            res = Math.min(res, cur);\n        }\n        return res;\n    }\n```\n\n**C++**\n```cpp\n    int minimumDeletions(string word, int k) {\n        vector<int> A(26);\n        for (char& c : word) {\n            A[c - \'a\']++;\n        }\n        int res = 1e6;\n        for (int x : A) {\n            int cur = 0;\n            for (int a : A) {\n                cur += (a < x) ? a : max(0, a - (x + k));\n            }\n            res = min(res, cur);\n        }\n        return res;\n    }\n```\n\n**Python**\n```py\n    def minimumDeletions(self, word: str, k: int) -> int:\n        A = Counter(word).values()\n        res = inf\n        for x in A:\n            cur = 0\n            for a in A:\n                cur += a if a < x else max(0, a - (x + k))\n            res = min(res, cur)\n        return res\n```\n
['C', 'Python', 'Java']