You are viewing a single comment's thread. Return to all comments →
private static void calculateSum(List<List<Integer>> arr) { int max = Integer.MIN_VALUE; for(int rowidx=0;rowidx<=3;rowidx++) { for(int colidx=0;colidx<=3;colidx++) { List<Integer> row1 = arr.get(rowidx); List<Integer> row2 = arr.get(rowidx+1); List<Integer> row3 = arr.get(rowidx+2); int row1sum = row1.get(colidx) + row1.get(colidx+1) + row1.get(colidx+2); int row2sum = row2.get(colidx+1); int row3sum = row3.get(colidx) + row3.get(colidx+1) + row3.get(colidx+2); max = Math.max(row1sum + row2sum + row3sum, max); } } System.out.println(max); }
Seems like cookies are disabled on this browser, please enable them to open this website
Java 2D Array
You are viewing a single comment's thread. Return to all comments →