forked from sPredictorX1708/Ultimate-Java-Resources
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavalist.java
More file actions
27 lines (26 loc) · 746 Bytes
/
javalist.java
File metadata and controls
27 lines (26 loc) · 746 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 test{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
List<Integer> li = new ArrayList<Integer>();
for(int i = 0;i<n;i++){
int k = sc.nextInt();
li.add(i,k);
}
int q = sc.nextInt();
for(int i = 0; i < q; i++){
String s = sc.next();
if(s.compareTo("Insert")==0){
int p = sc.nextInt();
int l = sc.nextInt();
li.add(p,l);
}
else{
int p = sc.nextInt();
li.remove(p);
}
}
li.forEach(nb -> System.out.print(nb + " "));
}
}