2D Array Traversal With Step
Consider the following method:
public void editArray(int[][] data) {
for (int row = 0; row < data.length; row += 2) {
for (int col = 0; col < data[row].length; col++) {
data[row][col] = -data[row][col];
}
}
}
Given an array data initialized as follows:
{
{-1, -2, -3},
{4, 5, 6},
{7, 8, 9},
{10, 11, 12}
}
What will the array look like after the method execution?
A
1, 2, 3
4, 5, 6
-7, -8, -9
-10, -11, -12
B
1, 2, 3
4, 5, 6
7, 8, 9
10, 11, 12
C
-1, -2, -3
4, 5, 6
7, 8, 9
10, 11, 12
D
1, 2, 3
4, 5, 6
-7, -8, -9
10, 11, 12
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kaisuki | 1 | 1 | 0m 00s | 100 |
| #2 | winstonhou1107 | 0 | 1 | 0m 00s | -10 |
| #3 | y.seong2027 | 1 | 2 | 1m 40s | -10 |
| #4 | bommasam000 | 1 | 3 | 11m 52s | -632 |
Items per page:
10
1 – 4 of 4
