You are viewing a single comment's thread. Return to all comments →
Pasted only the logic.
List<Integer> listOfSumOfHourGlass = new ArrayList<Integer>(); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { int topRow = (arr.get(i)).get(j) + (arr.get(i)).get(j+1) + (arr.get(i)).get(j+2); int midRow = (arr.get(i+1)).get(j+1); int bottomRow = (arr.get(i+2)).get(j) + (arr.get(i+2)).get(j+1) + (arr.get(i+2)).get(j+2); int sumOfHourGlassRows = topRow + midRow + bottomRow; listOfSumOfHourGlass.add(sumOfHourGlassRows); } } System.out.println(Collections.max(listOfSumOfHourGlass));
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 →
Pasted only the logic.