You are viewing a single comment's thread. Return to all comments →
Complexity O(N). One Loop.
static int diagonalDifference(int[][] a) { int row=0; int column=a[0].length - 1; int solution = 0; for(int index=0;index<a.length;index++){ solution -= a[row][row] - a[row++][column--]; } return Math.abs(solution); }
Seems like cookies are disabled on this browser, please enable them to open this website
Diagonal Difference
You are viewing a single comment's thread. Return to all comments →
Complexity O(N). One Loop.