We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
publicstaticvoidmain(String[]args){/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */Scannersc=newScanner(System.in);intN=sc.nextInt();List<Integer>numbers=newArrayList<>(N);for(inti=0;i<N;i++){intnum=sc.nextInt();numbers.add(num);}intQ=sc.nextInt();for(intquery=0;query<Q;query++){Stringop=sc.next();if(Objects.equals(op,"Insert")){intindex=sc.nextInt();intnum2=sc.nextInt();numbers.add(index,num2);}elseif(op.equals("Delete")){intrmNumber=sc.nextInt();numbers.remove(rmNumber);}}sc.close();for(inti:numbers){System.out.print(i+" ");}}}
Cookie support is required to access HackerRank
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 →