DE Shaw 2021 | Hard OA Question | 2D Prefix Sums & HashMaps
Question · Posted Jun 2026
Question 1: Number of Submatrices That Sum to Target Problem Statement Given a 2D matrix and an integer target, return the absolute total number of non-empty submatrices that sum to exactly the target value. A submatrix x1, y1, x2, y2 is the set of all cells matrix[x][y] with x1 <= x <= x2 and y1 <= y <= y2. Constraints 1 <= matrix.length <= 100 1 <= matrix[0].length <= 100 -1000 <= matrix[i][j] <= 1000 -108 <= target <= 108 ...
The full answer & interview discussion are available to premium members.
Log in Create a free account