Skip to content

Instantly share code, notes, and snippets.

@alexandervasyuk
Created October 2, 2014 17:50
Show Gist options
  • Save alexandervasyuk/7ee1142e4728e56e43eb to your computer and use it in GitHub Desktop.
Save alexandervasyuk/7ee1142e4728e56e43eb to your computer and use it in GitHub Desktop.
MatrixRegionSumNaive
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