Available question text
Given an immutable m×n matrix, design a data structure to return the sum of any sub-rectangle [row1..row2]×[col1..col2] in O(1) time; the core challenge is to preprocess the matrix (O(mn) space/time) with 2D cumulative/prefix sums to enable constant-time rectangle-sum queries.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 304. Range Sum Query 2D - Immutable
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source