-
Notifications
You must be signed in to change notification settings - Fork 0
/
Java_List.java
37 lines (32 loc) · 998 Bytes
/
Java_List.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
28
29
30
31
32
33
34
35
36
37
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
LinkedList<Integer> linkedList = new LinkedList<>();
for (int i = 0; i < n; i++) {
int l = scanner.nextInt();
linkedList.add(l);
}
int q = scanner.nextInt();
for (int j = 0; j < q; j++) {
String process = scanner.next();
if (process.equals("Insert")) {
int x = scanner.nextInt();
int y = scanner.nextInt();
linkedList.add(x,y);
}
else {
int x = scanner.nextInt();
linkedList.remove(x);
}
}
scanner.close();
for (Integer number : linkedList) {
System.out.print(number + " ");
}
}
}
// Caner Dabakoglu
// GitHub: https://github.com/cdabakoglu