NeetCode #100LC-304MediumArrays & HashingNC 250
← Back to All Problems#100 · #304 · Range Sum Query 2D - Immutable(二维区域和检索 - 矩阵不可变)
📌 Problem Statement & Constraints
Design a data structure that answers rectangle-sum queries on an immutable 2D matrix. Implement
NumMatrix(matrix) and sumRegion(row1, col1, row2, col2), where the query returns the sum of the submatrix with those inclusive corner coordinates. Constraints: 1 <= m, n <= 200; -10^4 <= matrix[i][j] <= 10^4; up to 10^4 queries.🔒
Sign In to Unlock Full Solutions for All 973 Problems
Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!