You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/java/com/fishercoder/solutions/_304.java
+2-27Lines changed: 2 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -1,30 +1,5 @@
1
1
packagecom.fishercoder.solutions;
2
2
3
-
/**
4
-
* 304. Range Sum Query 2D - Immutable
5
-
*
6
-
* Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).
7
-
8
-
Range Sum Query 2D
9
-
The above rectangle (with the red border) is defined by (row1, col1) = (2, 1) and (row2, col2) = (4, 3), which contains sum = 8.
10
-
11
-
Example:
12
-
Given matrix = [
13
-
[3, 0, 1, 4, 2],
14
-
[5, 6, 3, 2, 1],
15
-
[1, 2, 0, 1, 5],
16
-
[4, 1, 0, 1, 7],
17
-
[1, 0, 3, 0, 5]
18
-
]
19
-
20
-
sumRegion(2, 1, 4, 3) -> 8
21
-
sumRegion(1, 1, 2, 2) -> 11
22
-
sumRegion(1, 2, 2, 4) -> 12
23
-
Note:
24
-
You may assume that the matrix does not change.
25
-
There are many calls to sumRegion function.
26
-
You may assume that row1 ≤ row2 and col1 ≤ col2.
27
-
*/
28
3
publicclass_304 {
29
4
30
5
publicstaticclassSolution1 {
@@ -40,14 +15,14 @@ public NumMatrix(int[][] matrix) {
0 commit comments