You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.;
public class Solution {
public static void main(String[] args) { Scanner sc = new Scanner(System.in); int size = sc.nextInt(); ArrayList<Integer> list = new ArrayList<>(); for(int i = 0; i < size; i++){ list.add(i, sc.nextInt()); } int query = sc.nextInt(); for(int i = 0; i < query; i++){ String op = sc.next(); if(op.equals("Insert")){ list.add(sc.nextInt(), sc.nextInt()); }else if(op.equals("Delete")){ list.remove(sc.nextInt()); }else{ System.out.println("Wrong Input"); } } for(int element : list){ System.out.print(element + " "); } }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Java List
You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.;
public class Solution {
}