ProgrammingModerate
Sum of a 2 x 2 window of m[i][j] = i + j starting at (1,1) in a 4 x 4 grid, i.e. m[1][1] + m[1][2] + m[2][1] + m[2][2]. What is the value?
- A. 10
- B. 8
- C. 14
- D. 12
Correct answer: D. 12
The window holds m[1][1] = 2, m[1][2] = 3, m[2][1] = 3 and m[2][2] = 4, total 12. A topper's check: four cells symmetric around the average value 3 give 4 x 3 = 12, so 10 (one of the 3s counted as 1) is a slip.
More C Programming questions
- In a 2D array with int a[5][5], what is the total number of bytes in one row when int is 4 bytes?
- What is the most efficient way to check whether an n x n matrix is symmetric in O(n^2)?
- A 3 x 4 matrix holds a[i][j] = i 4 + j + 1. What is the sum of its boundary cells (first and last row, first and last column)?
- The number of ways to tile a 2 x 5 board exactly with 2 x 1 dominoes, counting orientations, is what?
- The length of the longest common subsequence of "ABCBDAB" and "BDCAB" is what?
- What is the Levenshtein edit distance between "kitten" and "sitting" (insert, delete, replace, each cost 1)?