ProgrammingHard
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?
- A. 45
- B. 40
- C. 41
- D. 37
Correct answer: B. 40
The boundary cells are 1, 2, 3, 6, 9, 8, 7, 4 and their sum is 40. The centre 5 is excluded.
More C Programming questions
- 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?
- char names[3][6] = {"ab", "cde"}; What is sizeof names[1]?