1647. Minimum Deletions to Make Character Frequencies Unique
T: O(n + 26log26), n is len of s
S: O(26)
```javaclassSolution {publicintminDeletions(String s) {int[] count =newint[26];for (int i =0; i <s.length(); i++) { count[s.charAt(i)-'a']++; }Arrays.sort(count);int keep = count[25];int prev = keep;for (int i =count.length-2; i >=0&& count[i] >0&& prev >0; i--) { prev =Math.min(prev-1, count[i]); keep += prev; }returns.length() - keep; }}/**T: O(n + 26log26), n is len of sS: O(26)bbcebabb: 3c: 1e: 1a: 1ans is 2 we will delete e and aso when prev is already 0, means can't keep doinghow to make unique? prev -1idea:origin:3 1 1 1after3 1 0 0origin:2 2 2after 2 1 0origin:5 4 4 3after:5 4 3 2so have to do this:min(prev-1, current value) */```