-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava List.java
More file actions
27 lines (27 loc) · 743 Bytes
/
Copy pathJava List.java
File metadata and controls
27 lines (27 loc) · 743 Bytes
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.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String I = "Insert";
String D = "Delete";
int N = sc.nextInt();
ArrayList<Integer> a1 = new ArrayList<Integer>(N);
for(int i=0;i<N;i++)
a1.add(sc.nextInt());
int Q = sc.nextInt();
for(int i=0;i<Q;i++){
String k = sc.next();
if(k.equals(I)){
int a = sc.nextInt();
int b = sc.nextInt();
a1.add(a,b);
}
else{
int c = sc.nextInt();
a1.remove(c);
}
}
for (int i=0; i<a1.size(); i++)
System.out.print(a1.get(i)+" ");
}
}