package leetcode;

import java.util.List;

/**
 * https://leetcode.com/problems/build-an-array-with-stack-operations/
 */
public class Problem1441 {
    public List<String> buildArray(int[] target, int n) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1441 prob = new Problem1441();
        System.out.println(prob.buildArray(new int[]{1,3}, 3)); // ["Push","Push","Pop","Push"]
        System.out.println(prob.buildArray(new int[]{1,2,3}, 3)); // ["Push","Push","Push"]
        System.out.println(prob.buildArray(new int[]{1,2}, 4)); // ["Push","Push"]
        System.out.println(prob.buildArray(new int[]{2,3,4}, 4)); // ["Push","Pop","Push","Push","Push"]
    }
}

@@ -12,16 +12,44 @@
 tcode;%0A%0A
+import java.util.ArrayList;%0A
 import j
@@ -63,16 +63,16 @@
 l.List;%0A
-
 %0A/**%0A * 
@@ -240,322 +240,275 @@
     
-// TODO%0A        return null
+List%3CString%3E answer = new ArrayList%3C%3E();%0A        int j = 0
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1441 prob = new Problem1441();%0A        System.out.println(prob.buildArray(new int%5B%5D%7B1,3%7D, 3)); // %5B%22Push%22,%22Push%22,%22Pop%22,%22Push%22%5D%0A        System.out.println(prob.buildArray(new int%5B%5D%7B1,2,3%7D, 3)); // %5B%22Push%22,%22Push%22,
+for (int i = 1; i %3C= n && j %3C target.length; i++) %7B%0A            if (i == target%5Bj%5D) %7B%0A                answer.add(%22Push%22);%0A                j++;%0A            %7D else %7B%0A                answer.add(
 %22Push%22
-%5D
+);
 %0A   
@@ -516,187 +516,81 @@
     
-System.out.println(prob.buildArray(new int%5B%5D%7B1,2%7D, 4)); // %5B%22Push%22,%22Push%22%5D%0A        System.out.println(prob.buildArray(new int%5B%5D%7B2,3,4%7D, 4)); // %5B%22Push%22,%22Pop%22,%22Push%22,%22Push%22,%22Push%22%5D
+        answer.add(%22Pop%22);%0A            %7D%0A        %7D%0A        return answer;
 %0A   

Solve problem 1441