- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJavaArraylist.java
More file actions
Latest commit
33 lines (29 loc) · 967 Bytes
/
Copy pathJavaArraylist.java
File metadata and controls
33 lines (29 loc) · 967 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
packageDataStructure;
importjava.util.*;
publicclassJavaArraylist {
publicstaticvoidmain(String[] args) {
Scannerscan = newScanner(System.in);
intcount = scan.nextInt(), query, number;
List<List<Integer>> numbers = newArrayList<>();
for (intx = 0; x < count; x++) {
numbers.add(newArrayList<>());
query = scan.nextInt();
for (inty = 0; y < query; y++) {
number = scan.nextInt();
numbers.get(x).add(number);
}
}
count = scan.nextInt();
List<Integer> tmp;
for (intx = 0; x < count; x++) {
query = scan.nextInt();
number = scan.nextInt();
tmp = numbers.get(query - 1);
if (tmp.size() > number - 1) {
System.out.println(tmp.get(number - 1));
} else {
System.out.println("ERROR!");
}
}
}
}