C++ using memo and sort-counting
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int dp[27][27];\n    int solve(vector<int> &nums, int i, int j, int k)\n    {\n        if(i>=j) return 0;\n\n        if(dp[i][j]!=-1) return dp[i][j];\n        int a = nums[i] + solve(nums, i+1, j, k);\n        int x = (nums[j]-nums[i])-k;\n        int b = ( x >= 0 ? x : 0 )+ solve(nums, i, j-1, k);\n \n        return dp[i][j] = min(a, b);\n    }\n    int minimumDeletions(string word, int k) {\n        \n        unordered_map<char,int> mp;\n        for(auto i:word) mp[i]++;\n\n        vector<int> nums;\n        for(auto i:mp) nums.push_back(i.second);\n        sort(nums.begin(), nums.end());\n        memset(dp, -1, sizeof(dp));\n\n        return solve(nums, 0, nums.size()-1, k);\n\n    }\n};\n```
['C++']