@@ -0,0 +1,1812 @@
+import java.util.Arrays;%0A%0Apublic class Solution %7B%0A%0A    public int leastInterval(char%5B%5D tasks, int n) %7B%0A        int%5B%5D cnt = new int%5B26%5D;%0A        int%5B%5D prev = new int%5B26%5D;%0A        for (int i = 0; i %3C 26; i ++) %7B%0A            cnt%5Bi%5D = 0;%0A            prev%5Bi%5D = -1;%0A        %7D%0A        int rnd = 0;%0A        int maxn = 0;%0A        for (int i = 0; i %3C tasks.length; i ++) %7B%0A            cnt%5Btasks%5Bi%5D - 'A'%5D += 1;%0A            rnd += 1;%0A        %7D%0A       %0A/*%0Afor(int i = 0; i %3C 26; i ++) %7B%0A            if (cnt%5Bi%5D %3E maxn) %7B%0A                maxn = i;%0A            %7D%0A        %7D%0A        %0A        prev%5Bmaxn%5D = 1;%0A        cnt%5Bmaxn%5D -= 1;%0A        rnd -= 1;%0A        int t = 1;%0A*/%0A        int t =0;%0A        while (rnd %3E 0) %7B%0A            t += 1;%0A            Arrays.sort(cnt);%0A            boolean has = false;%0A            for(int i = 25; i %3E= 0; i --) %7B%0A                if (cnt%5Bi%5D == 0) %7B%0A                    continue;%0A                %7D%0A                %0A                if (prev%5Bi%5D %3C= 0) %7B%0A                    prev%5Bi%5D = t;%0A                    cnt%5Bi%5D -= 1;%0A                 has=true;%0A                 rnd -= 1;%0A                System.out.println(i);%0A                    break;%0A                %7D%0A                %0A                if (t - prev%5Bi%5D %3E n) %7B%0A                    prev%5Bi%5D = t;%0A                    cnt%5Bi%5D -= 1;%0A                    rnd -= 1;%0A                 has=true;%0A                System.out.println(i);%0A                    break;%0A                %7D%0A            %7D%0A            if (!has) %7B%0A                System.out.println(%22null%22); %0A            %7D%0A        %7D%0A        return t;%0A    %0A    %7D%0A    %0A    public static void main(String %5B%5D args) %7B%0A        Solution sol = new Solution();%0A        char%5B%5Dcs=%7B'A','A','A','B','B','B'%7D;%0A        int n = 1;%0A        int ans = sol.leastInterval(cs, n);%0A        System.out.println(%22ans %22 + ans);%0A    %7D%0A%7D%0A

add solution for week37 D