package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/relative-sort-array/
 */
public class Problem1122 {
    public int[] relativeSortArray(int[] arr1, int[] arr2) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1122 prob = new Problem1122();
        System.out.println(Arrays.toString(prob.relativeSortArray(
            new int[]{2, 3, 1, 3, 2, 4, 6, 7, 9, 2, 19},
            new int[]{2, 1, 4, 3, 9, 6}))); // [2,2,2,1,4,3,3,9,6,7,19]
    }
}

@@ -16,34 +16,8 @@
 e;%0A%0A
-import java.util.Arrays;%0A%0A
 /**%0A
@@ -174,330 +174,656 @@
     
-// TODO%0A        return null;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1122 prob = new Problem1122();%0A        System.out.println(Arrays.toString(prob.relativeSortArray(
+int%5B%5D counts = new int%5B1001%5D;%0A        for (int i = 0; i %3C arr1.length; i++) %7B%0A            counts%5Barr1%5Bi%5D%5D++;%0A        %7D%0A        int index = 0;%0A        int%5B%5D answer = new int%5Barr1.length%5D;%0A        for (int i = 0; i %3C arr2.length; i++) %7B%0A            for (int j = 0; j %3C counts%5Barr2%5Bi%5D%5D; j++) %7B%0A                answer%5Bindex++%5D = arr2%5Bi%5D;%0A            %7D%0A            counts%5Barr2%5Bi%5D%5D = 0;
 %0A     
+   %7D%0A
        
-new int%5B%5D%7B2, 3, 1, 3, 2, 4, 6, 7, 9, 2, 19%7D,%0A            new int%5B%5D%7B2, 1, 4, 3, 9, 6%7D))); // %5B2,2,2,1,4,3,3,9,6,7,19%5D
+ for (int i = 0; i %3C counts.length; i++) %7B%0A            if (counts%5Bi%5D == 0) %7B%0A                continue;%0A            %7D%0A            for (int j = 0; j %3C counts%5Bi%5D; j++) %7B%0A                answer%5Bindex++%5D = i;%0A            %7D%0A        %7D%0A        return answer;
 %0A   

Solve problem 1122