You are viewing a single comment's thread. Return to all comments →
the sample test case is passed but all other test cases got failed
Scanner sc = new Scanner(System.in); int n = sc.nextInt();
List<Integer> l = new ArrayList<>(n); for(int i =0; i<n; i++){ l.add(sc.nextInt()); } int q = sc.nextInt(); sc.nextLine(); for(int i =0; i<q; i++ ){ String str = sc.nextLine().trim(); if(str.equalsIgnoreCase("Insert")){ int index = sc.nextInt(); int value = sc.nextInt(); sc.nextLine(); l.add(index,value); } if(str.equalsIgnoreCase("Delete")){ int removeindex = sc.nextInt(); l.remove(removeindex); } } l.forEach(l1 -> System.out.print(l1 + " "));
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 →
the sample test case is passed but all other test cases got failed
Scanner sc = new Scanner(System.in); int n = sc.nextInt();