You are viewing a single comment's thread. Return to all comments →
int biggestSum = Integer.MIN_VALUE;
for(int i = 0; i< arr.size()-2 ;i++){ List<Integer> firstRow = arr.get(i); List<Integer> secondRow = arr.get(i+1); List<Integer> ThirdRow = arr.get(i+2); for(int j =0; j<arr.size()-2; j++){ int hourGlassSum = firstRow.get(j) + firstRow.get(j+1) + firstRow.get(j+2)+ secondRow.get(j+1)+ ThirdRow.get(j)+ThirdRow.get(j+1)+ThirdRow.get(j+2); biggestSum= Math.max(hourGlassSum, biggestSum); } } System.out.println(biggestSum);
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 →
int biggestSum = Integer.MIN_VALUE;