Process Mutable Matrix Sum Queries
Company: LinkedIn
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Take-home Project
Quick Answer: This question evaluates a candidate's understanding of efficient mutable 2D range-query and point-update data structures and algorithms for computing submatrix sums under dynamic updates, and falls under the Coding & Algorithms domain.
Constraints
- 1 <= rows, cols <= 500
- 1 <= rows * cols <= 100000
- 0 <= len(queries) <= 200000
- -10^9 <= matrix[r][c], v <= 10^9
- For 'set' queries: 0 <= r < rows and 0 <= c < cols
- For 'get' queries: 0 <= r1 <= r2 <= rows and 0 <= c1 <= c2 <= cols
Examples
Input: ([[1, 2, 3], [4, 5, 6]], ['get 0 2 1 3', 'set 0 1 10', 'get 0 2 1 3', 'set 0 0 -3', 'get 0 1 0 2'])
Expected Output: [16, 24, 7]
Explanation: The first query sums columns 1..2 across both rows: 2 + 3 + 5 + 6 = 16. After setting matrix[0][1] = 10, the same rectangle sums to 10 + 3 + 5 + 6 = 24. After setting matrix[0][0] = -3, the final query asks for the first row, first two columns: -3 + 10 = 7.