-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLists.java
More file actions
39 lines (32 loc) · 747 Bytes
/
Lists.java
File metadata and controls
39 lines (32 loc) · 747 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
28
29
30
31
32
33
34
35
36
37
38
39
/*
https://www.hackerrank.com/challenges/java-list
*/
import java.util.Scanner;
import java.util.List;
import java.util.Vector;
public class Main{
public static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
int n = input.nextInt();
List<Integer> list = new Vector<>();
for(int i=0;i<n;i++)
list.add(input.nextInt());
int q = input.nextInt();
String query;
int x,y;
for(int i=0;i<q;i++){
query = input.next().toLowerCase();
if(query.equals("insert")){
x = input.nextInt();
y = input.nextInt();
list.add(x,y);
}
else if(query.equals("delete")){
x = input.nextInt();
list.remove(x);
}
}
for(int element : list)
System.out.print(element+" ");
}
}