Memoization DP JAVA
IntuitionTarget : To get minDeletion to get the character freq in range k
In order to minimise :
we can either delete the character with least freq , hence del
# Intuition
Target : To get minDeletion to get the character freq in range k
In order to minimise :
 - we can either `delete the character with least freq` , hence del of character with least freq
 -` Delete the character with highest freq `


# Approach
- Get all character freq in Array
- Then Sort the freqArray in ascending
- Make memo[i][j] , i, j are limit ie left , right with int the freqArray (26 letter) in order dp[l][r] contains the minimum deletions with the leftEnd and rightEnd
- 2 CHOICES : 
    1. LEFT DELETION : include the freq[l] int deleted cnt and recursive cal : dp[l+1], [r]
    2. RIGHT DELETION : include freq[r] (exclude the valid range freq[l]+ k) & rec call dp[l][r-1] 
    
Choose the mini of both 
# Complexity
- Time complexity: O(n*26*26)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(26*26)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public int minimumDeletions(String word, int k) {
        int[] freq = new int[26];

        for (char ch : word.toCharArray()){
            freq[ch - 'a'] += 1;
        }
        Arrays.sort(freq);

        int[][] memo=  new int[26][26];
        for (int[] row : memo){
            Arrays.fill(row, Integer.MAX_VALUE );
        }
        // we have 2 options of deletions right / left from subarrays
        Arrays.sort(freq);
        return getMinDel(word, 0, 25, k, freq , memo);
    }
    private int getMinDel(String word, int l , int r, int k, int[] freq, int[][] memo){
        if (memo[l][r] != Integer.MAX_VALUE) return memo[l][r];
        if (freq[r] - freq[l] <= k) return 0 ;// no deletions required 
        // 2 option fo deletions 
        int rightDel = freq[r] -  (freq[l]+k) + getMinDel(word, l, r-1 ,k, freq, memo);
        int leftDel = freq[l] + getMinDel(word, l+1, r,k, freq , memo);
         
        return memo[l][r] = Math.min(rightDel, leftDel);
    }
}
```
['Java']