Skip to content

Commit b274df6

Browse files
update 1314
1 parent cc8fdb3 commit b274df6

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/main/java/com/fishercoder/solutions/secondthousand/_1314.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55

66
public class _1314 {
77
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) {
912
int m = mat.length;
1013
int n = mat[0].length;
1114
int[][] answer = new int[m][n];
1215
for (int i = 0; i < m; i++) {
1316
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);
1619
int sum = 0;
1720
for (int ii = 0; ii < iRange.size(); ii++) {
1821
for (int jj = 0; jj < jRange.size(); jj++) {

src/test/java/com/fishercoder/secondthousand/_1314Test.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
package com.fishercoder.secondthousand;
22

33
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;
66

7-
import static org.junit.Assert.assertEquals;
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
88

99
public class _1314Test {
1010
private static _1314.Solution1 solution1;
1111
private static int[][] mat;
1212
private static int[][] expected;
1313

14-
@BeforeClass
15-
public static void setup() {
14+
@BeforeEach
15+
public void setup() {
1616
solution1 = new _1314.Solution1();
1717
}
1818

0 commit comments

Comments
 (0)