You are viewing a single comment's thread. Return to all comments →
public static void main(String[] args) { Scanner sc = new Scanner(System.in); int len = sc.nextInt();
List<Integer> list = new ArrayList<>(); for (int i = 0; i < len; ++i) { list.add(sc.nextInt()); } Query insert = (sc12, l) -> l.add(sc12.nextInt(), sc12.nextInt()); Query delete = (sc1, l) -> l.remove(sc1.nextInt()); Map<String, Query> map = new HashMap<>() {{ put("insert", insert); put("delete", delete); }}; int query = sc.nextInt(); for (int i = 0; i < query; ++i) { sc.nextLine(); map.get(sc.nextLine().toLowerCase()).execute(sc, list); } System.out.println(list.stream().map(Object::toString).collect(Collectors.joining(" ")));
}
interface Query { void execute(Scanner sc, List l); }
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 →
public static void main(String[] args) { Scanner sc = new Scanner(System.in); int len = sc.nextInt();
}
interface Query { void execute(Scanner sc, List l); }