Created
October 2, 2014 17:50
-
-
Save alexandervasyuk/7ee1142e4728e56e43eb to your computer and use it in GitHub Desktop.
MatrixRegionSumNaive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int matrixRegionSumNaive(int[][] matrix, Coordinate A, Coordinate D) { | |
int result = 0; | |
for (int j = A.y; j < matrix.length; j++) { | |
for (int i = A.x; i < matrix[0].length; i++) { | |
result += matrix[i][j]; | |
} | |
} | |
return result; | |
} | |
public class Coordinate { | |
protected int x; | |
protected int y; | |
public Coordinate(int x, int y) { | |
this.x = x; | |
this.y = y; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment