Here you can find the source of summedDifference(int[][] matrix, short topX, short botX, short row)
public static int summedDifference(int[][] matrix, short topX, short botX, short row)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; public class Main { public static int summedDifference(int[][] matrix, short topX, short botX, short row) { int n = matrix[0].length - 1; int sums[] = new int[4]; sums[1] = matrix[topX][row];/*w w w . jav a 2s . c om*/ sums[0] = matrix[n][row] - sums[1]; sums[2] = matrix[botX][n] - matrix[botX][row]; sums[3] = matrix[n][n] - sums[0] - sums[2] - sums[1]; Arrays.sort(sums); return sums[3] - sums[0]; } }