You are viewing a single comment's thread. Return to all comments →
Hi hackers, here is my java code..
public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); List<Integer> lst = new ArrayList<>(); for (int i = 0; i < N; i++) { lst.add(sc.nextInt()); } int Q = sc.nextInt(); while (Q-- > 0) { switch (sc.next()) { case "Insert": lst.add(sc.nextInt(), sc.nextInt()); break; case "Delete": lst.remove(sc.nextInt()); break; default: System.out.println("Invalid operation."); System.exit(-1); break; } } sc.close(); while (!lst.isEmpty()) { System.out.print(lst.remove(0) + " "); } }
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 →
Hi hackers, here is my java code..