-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathLists.java
27 lines (25 loc) · 845 Bytes
/
Lists.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.io.*;
import java.util.*;
public class Lists {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner in = new Scanner(System.in);
int len = in.nextInt();
LinkedList<Integer> list = new LinkedList<>();
for(int i = 0; i < len; i++)
list.add(in.nextInt());
int j = in.nextInt();
for(int i = 0; i < j; i++){
switch(in.next()){
case "Insert":
list.add(in.nextInt(), in.nextInt());
break;
case "Delete":
list.remove(in.nextInt());
break;
}
}
for(Integer i:list)
System.out.print(i+" ");
}
}