ProgrammingVery hard
The zigzag scan of the 3 x 3 matrix [[1,2,3],[4,5,6],[7,8,9]] along anti-diagonals, alternating direction (as in JPEG order), gives which sequence?
- A. 1 2 4 7 5 3 6 8 9
- B. 1 2 3 6 9 8 7 4 5
- C. 1 4 7 8 9 6 3 2 5
- D. 1 2 4 5 7 8 3 6 9
Correct answer: A. 1 2 4 7 5 3 6 8 9
The anti-diagonals are visited in order, and each one alternates direction, giving 1, 2, 4, 7, 5, 3, 6, 8, 9.
More C Programming questions
- In the 3 x 3 matrix [[1,2,3],[4,5,6],[7,8,9]], what is the sum of the boundary cells, leaving the centre out?
- For a 4 x 4 matrix with a[i][j] = 4i + j, what is the sum of the anti-diagonal cells (i, 3 - i)?
- Using a largest-square DP on grid rows [1,0,1,1], [1,1,1,1], [1,1,1,0], what is the side of the largest all-ones square?
- A grid DP that counts right/down paths for 1000 x 1000 cells should use what memory layout to stay small?
- Which approach finds the maximum sum rectangle in an n x n int matrix with n = 500 within a second in C?
- int a[2][3]; with two rows and three columns in a variable-length array, what is sizeof(a) on a platform with 4-byte int?