You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*; import java.util.ArrayList; import java.util.Arrays;
public class Solution {
public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n =sc.nextInt(); ArrayList<Integer> list = new ArrayList<>(); for(int i=0;i<n;i++){ list.add(sc.nextInt()); } n=sc.nextInt(); for(int i=0;i<n;i++){ String str=sc.next(); if(str.equals("Insert")){ int a=sc.nextInt(); int b=sc.nextInt(); list.add(a, b); } if(str.equals("Delete")){ int a = sc.nextInt(); list.remove(a); } }for (int j : list) { System.out.print(j + " "); } sc.close(); }
}
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.; import java.text.; import java.math.; import java.util.regex.*; import java.util.ArrayList; import java.util.Arrays;
public class Solution {
}