You are viewing a single comment's thread. Return to all comments →
public class Solution { public static void main(String[] args) { Scanner in=new Scanner(System.in); int n=in.nextInt(); List<Integer> list=new ArrayList<>(n); for(int i=0;i<n;i++){ list.add(in.nextInt()); } int q=in.nextInt(); for(int j=0;j<q;j++){ String str=in.next(); if(str.equalsIgnoreCase("Insert")){ int x=in.nextInt(); int y=in.nextInt(); list.add(x,y); } if(str.equalsIgnoreCase("delete")){ int z=in.nextInt(); list.remove(z); } } for(int num:list){ System.out.print(num+" "); } } }
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 →