-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava-list.java
More file actions
36 lines (33 loc) · 971 Bytes
/
java-list.java
File metadata and controls
36 lines (33 loc) · 971 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
// Happy Coding :)
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here.
Read input from STDIN. Print output to STDOUT.
Your class should be named Solution. */
Scanner s = new Scanner(System.in);
List<Integer> list = new ArrayList<Integer>();
int n = s.nextInt();
for(int i=0;i<n;i++)
list.add(s.nextInt());
int q = s.nextInt();
for(int j=0;j<q;j++)
{
String op = s.next();
if(op.compareTo("Insert")==0)
{
int pos = s.nextInt();
int val = s.nextInt();
list.add(pos,val);
}
else
{
int pos = s.nextInt();
list.remove(pos);
}
}
for(int k=0;k<list.size();k++)
System.out.print(list.get(k)+" ");
s.close();
}
}