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.
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int l = scan.nextInt();
List<Integer> list = new ArrayList<>(l);
for(int i = 0; i<l; i++){
list.add(scan.nextInt());
}
int q = scan.nextInt();
for(int i= 0; i<q; i++){
String b = scan.next();
if("Insert".equalsIgnoreCase(b)){
int x = scan.nextInt();
int y = scan.nextInt();
list.add(x, y);
}
if("Delete".equalsIgnoreCase(b)){
int x = scan.nextInt();
list.remove(x);
}
}
list.forEach(i->{System.out.print(i+" ");});
scan.close();
}
}
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 →
import java.io.; import java.util.;
public class Solution {
}