@@ -0,0 +1,948 @@
+package leetcode;%0A%0Aimport java.util.Arrays;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0A/**%0A * https://leetcode.com/problems/sort-array-by-increasing-frequency/%0A */%0Apublic class Problem1636 %7B%0A    public int%5B%5D frequencySort(int%5B%5D nums) %7B%0A        Map%3CInteger, Integer%3E map = new HashMap%3C%3E();%0A        Integer%5B%5D sorted = new Integer%5Bnums.length%5D;%0A        for (int i = 0; i %3C nums.length; i++) %7B%0A            sorted%5Bi%5D = nums%5Bi%5D;%0A            map.put(nums%5Bi%5D, map.getOrDefault(nums%5Bi%5D, 0) + 1);%0A        %7D%0A        Arrays.sort(sorted, (a, b) -%3E %7B%0A            int count1 = map.get(a);%0A            int count2 = map.get(b);%0A            if (count1 == count2) %7B%0A                return Integer.compare(b, a);%0A            %7D%0A            return Integer.compare(count1, count2);%0A        %7D);%0A        int%5B%5D answer = new int%5Bnums.length%5D;%0A        for (int i = 0; i %3C sorted.length; i++) %7B%0A            answer%5Bi%5D = sorted%5Bi%5D;%0A        %7D%0A        return answer;%0A    %7D%0A%7D%0A

Solve problem 1636