@@ -0,0 +1,2164 @@
+package java_problems.data_structures;%0D%0A%0D%0Aimport java.util.ArrayList;%0D%0Aimport java.util.Scanner;%0D%0A%0D%0A/*%0D%0A * Given a list, L, of N integers, perform Q queries on the list. Once all queries%0D%0A * are completed, print the modified list as a single line of space-separated%0D%0A * integers.%0D%0A * %0D%0A * Input Format: %0D%0A * The first line contains an integer, N (the initial number of elements in L).%0D%0A * The second line contains N space-separated integers describing L.%0D%0A * The third line contains an integer, Q (the number of queries).%0D%0A * The 2Q subsequent lines describe the queries, and each query is described over%0D%0A * two lines:%0D%0A * %0D%0A * If the first line of a query contains the String Insert, then the second line%0D%0A * contains two space separated integers x and y , and the value y must be inserted into%0D%0A * L at index x.%0D%0A * If the first line of a query contains the String Delete, then the second line%0D%0A * contains index x, whose element must be deleted from L.%0D%0A * %0D%0A * Constraints:%0D%0A * 1 %3C= N %3C= 4000%0D%0A * 1 %3C= Q %3C= 4000 %0D%0A * Each element in is a 32-bit integer.%0D%0A * %0D%0A * Output Format: %0D%0A * Print the updated list as a single line of space-separated integers.%0D%0A * %0D%0A * Sample Input: %0D%0A * 5%0D%0A * 12 0 1 78 12%0D%0A * 2%0D%0A * Insert%0D%0A * 5 23%0D%0A * Delete%0D%0A * 0%0D%0A * %0D%0A * Sample Output: %0D%0A * 0 1 78 12 23%0D%0A */%0D%0Apublic class JavaList %7B%0D%0A%0D%0A    public static void main(String%5B%5D args) %7B%0D%0A        Scanner sc = new Scanner(System.in);%0D%0A        int numElements = sc.nextInt();%0D%0A        %0D%0A        ArrayList%3CInteger%3E aList = new ArrayList%3C%3E();%0D%0A        for (int i = 0; i %3C numElements; i++) %7B%0D%0A            aList.add(sc.nextInt());%0D%0A        %7D%0D%0A        int numQueries = sc.nextInt();%0D%0A        for (int i = 0; i %3C numQueries; i++) %7B%0D%0A            String command = sc.next();%0D%0A            if (command.equals(%22Insert%22)) %7B%0D%0A                int index = sc.nextInt();%0D%0A                int value = sc.nextInt();%0D%0A                aList.add(index, value);%0D%0A            %7D else %7B%0D%0A                int index = sc.nextInt();%0D%0A                aList.remove(index);%0D%0A            %7D%0D%0A        %7D%0D%0A        for (int num : aList) %7B%0D%0A            System.out.print(num + %22 %22);%0D%0A        %7D%0D%0A        sc.close();%0D%0A    %7D%0D%0A%7D

Add JavaList