File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed
main/java/com/fishercoder/solutions/secondthousand
test/java/com/fishercoder/secondthousand Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 5
5
6
6
public class _1314 {
7
7
public static class Solution1 {
8
- public int [][] matrixBlockSum (int [][] mat , int K ) {
8
+ /**
9
+ * This is a brute force solution without using prefix sum. i.e. lots of repeated computation.
10
+ */
11
+ public int [][] matrixBlockSum (int [][] mat , int k ) {
9
12
int m = mat .length ;
10
13
int n = mat [0 ].length ;
11
14
int [][] answer = new int [m ][n ];
12
15
for (int i = 0 ; i < m ; i ++) {
13
16
for (int j = 0 ; j < n ; j ++) {
14
- List <Integer > iRange = findRange (i , K , m );
15
- List <Integer > jRange = findRange (j , K , n );
17
+ List <Integer > iRange = findRange (i , k , m );
18
+ List <Integer > jRange = findRange (j , k , n );
16
19
int sum = 0 ;
17
20
for (int ii = 0 ; ii < iRange .size (); ii ++) {
18
21
for (int jj = 0 ; jj < jRange .size (); jj ++) {
Original file line number Diff line number Diff line change 1
1
package com .fishercoder .secondthousand ;
2
2
3
3
import com .fishercoder .solutions .secondthousand ._1314 ;
4
- import org .junit .BeforeClass ;
5
- import org .junit .Test ;
4
+ import org .junit .jupiter . api . BeforeEach ;
5
+ import org .junit .jupiter . api . Test ;
6
6
7
- import static org .junit .Assert .assertEquals ;
7
+ import static org .junit .jupiter . api . Assertions .assertEquals ;
8
8
9
9
public class _1314Test {
10
10
private static _1314 .Solution1 solution1 ;
11
11
private static int [][] mat ;
12
12
private static int [][] expected ;
13
13
14
- @ BeforeClass
15
- public static void setup () {
14
+ @ BeforeEach
15
+ public void setup () {
16
16
solution1 = new _1314 .Solution1 ();
17
17
}
18
18
You can’t perform that action at this time.
0 commit comments