package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/create-target-array-in-the-given-order/
 */
public class Problem1389 {
    public int[] createTargetArray(int[] nums, int[] index) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1389 prob = new Problem1389();
        System.out.println(Arrays.toString(prob.createTargetArray(
            new int[]{0,1,2,3,4}, new int[]{0,1,2,2,1}))); // [0,4,1,3,2]
        System.out.println(Arrays.toString(prob.createTargetArray(
            new int[]{1,2,3,4,0}, new int[]{0,1,2,3,0}))); // [0,1,2,3,4]
        System.out.println(Arrays.toString(prob.createTargetArray(
            new int[]{1}, new int[]{0}))); // [1]
    }
}

@@ -16,34 +16,8 @@
 e;%0A%0A
-import java.util.Arrays;%0A%0A
 /**%0A
@@ -194,533 +194,432 @@
     
-// TODO%0A        return null
+int%5B%5D answer = new int%5B0%5D
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1389 prob = new Problem1389();%0A        System.out.println(Arrays.toString(prob.createTargetArray(%0A            new int%5B%5D%7B0,1,2,3,4%7D, new int%5B%5D%7B0,1,2,2,1%7D))); // %5B0,4,1,3,2%5D%0A        System.out.println(Arrays.toString(prob.createTargetArray(%0A            new int%5B%5D%7B1,2,3,4,0%7D, new int%5B%5D%7B0,1,2,3,0%7D))); // %5B0,1,2,3,4%5D%0A        System.out.println(Arrays.toString(prob.createTargetArray(%0A            new int%5B%5D%7B1%7D, new int%5B%5D%7B0%7D))); // %5B1%5D
+for (int i = 0; i %3C nums.length; i++) %7B%0A            int%5B%5D tmp = new int%5Bi + 1%5D;%0A            for (int j = 0; j %3C index%5Bi%5D; j++) %7B%0A                tmp%5Bj%5D = answer%5Bj%5D;%0A            %7D%0A            for (int j = index%5Bi%5D; j %3C answer.length; j++) %7B%0A                tmp%5Bj + 1%5D = answer%5Bj%5D;%0A            %7D%0A            tmp%5Bindex%5Bi%5D%5D = nums%5Bi%5D;%0A            answer = tmp;%0A        %7D%0A        return answer;
 %0A   

Solve problem 1389