package leetcode;

/**
 * https://leetcode.com/problems/minimum-deletions-to-make-character-frequencies-unique/
 */
public class Problem1647 {
    public int minDeletions(String s) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1647 prob = new Problem1647();
        System.out.println(prob.minDeletions("aab")); // 0
        System.out.println(prob.minDeletions("aaabbbcc")); // 2
        System.out.println(prob.minDeletions("ceabaacb")); // 2
    }
}

@@ -12,16 +12,42 @@
 tcode;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * h
@@ -214,318 +214,624 @@
     
-// TODO%0A        return 0;%0A
+int%5B%5D counts = new int%5B26%5D;%0A        for (char c : s.toCharArray()) %7B%0A            counts%5Bc - 'a'%5D++;%0A   
     
+ 
 %7D
-%0A
 %0A    
-public static void main(String%5B%5D args) %7B%0A        Problem1647 prob = new Problem1647();%0A        System.out.println(prob.minDeletions(%22aab%22)); // 0%0A        System.out.println(prob.minDeletions(%22aaabbbcc%22)); // 2%0A        System.out.println(prob.minDeletions(%22ceabaacb%22)); // 2
+    Arrays.sort(counts);%0A        int answer = 0;%0A        for (int i = counts.length - 1; i %3E 0; i--) %7B%0A            if (counts%5Bi%5D == 0) %7B%0A                int delete = counts%5Bi - 1%5D - counts%5Bi%5D;%0A                answer += delete;%0A                counts%5Bi - 1%5D -= delete;%0A            %7D else if (counts%5Bi%5D %3C= counts%5Bi - 1%5D) %7B%0A                int delete = counts%5Bi - 1%5D - counts%5Bi%5D + 1;%0A                answer += delete;%0A                counts%5Bi - 1%5D -= delete;%0A            %7D%0A        %7D%0A        return answer;
 %0A   

Solve problem 1647