- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathJavaArraylist.java
More file actions
Latest commit
28 lines (23 loc) · 878 Bytes
/
Copy pathJavaArraylist.java
File metadata and controls
28 lines (23 loc) · 878 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
// https://www.hackerrank.com/challenges/java-arraylist/problem
importhelper.InputHelper;
publicclassJavaArraylist {
publicstaticvoidmain(String[] args) {
intlength = InputHelper.takeLength();
int[][] matrix = newint[length][];
for (introw = 0 ; row < length ; row++) {
intcolumns = InputHelper.takeLength();
matrix[row] = newint[columns];
matrix[row] = InputHelper.get1DArray(columns);
}
intqueries = InputHelper.takeLength();
while (queries-- > 0) {
introw = InputHelper.takeLength();
intcolumn = InputHelper.takeLength();
System.out.println(
row - 1 < length && column - 1 < matrix[row - 1].length
? matrix[row - 1][column - 1]
: "ERROR!"
);
}
}
}