ProgrammingHard
For a 4 x 4 matrix with a[i][j] = 4i + j, what is the sum of the anti-diagonal cells (i, 3 - i)?
- A. 34
- B. 28
- C. 30
- D. 36
Correct answer: C. 30
The cells are 3, 6, 9 and 12, which sum to 30. Summing the main diagonal would give 34 instead.
More C Programming questions
- 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?
- char names[3][6] = {"ab", "cde"}; What is sizeof names[1]?
- Which statement about memset(a, 0, sizeof a) for a 2D int array a[4][5] is correct?