-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJavaList.java
41 lines (31 loc) · 1023 Bytes
/
JavaList.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
38
39
40
41
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
List<Integer> integers = new ArrayList<>();
for(int i = 0; i<n; i++){
int v = s.nextInt();
integers.add(v);
}
int q = s.nextInt();
for(int i = 0; i<q; i++){
String q2 = s.next();
if(q2.contains("Insert")){
int index = s.nextInt();
int value = s.nextInt();
integers.add(index, value);
}else if(q2.contains("Delete")){
int deleteIndex = s.nextInt();
integers.remove(deleteIndex);
}
}
for(int i = 0; i<integers.size(); i++){
System.out.print(integers.get(i)+ " ");
}
}
}