Assume below that when the method is called, n is the number of rows; and m is the number of columns.
public class TimeComplexity
public static int sum(double[] data, int n, int m) {
int i; // for the row index
int j; // for the column index
double sum = 0;
for (i = 0; i < n; i++) {
for (j = i; j < i + 2 && j < m + 2;j++) {
sum += a[i][j]
}
}
return sum;
}