You are viewing a single comment's thread. Return to all comments →
My Java 8 Solution:
public static int hourglassSum(List<List<Integer>> arr) { int max = Integer.MIN_VALUE; for (int row = 0; row < 4; row++) { for (int col = 0; col < 4; col++ ) { int sum = arr.get(row).get(col) + arr.get(row).get(col + 1) + arr.get(row).get(col + 2) + arr.get(row + 1).get(col + 1) + arr.get(row + 2).get(col) + arr.get(row + 2).get(col + 1) + arr.get(row + 2).get(col + 2); if (sum > max) { max = sum; } } } return max; }
Seems like cookies are disabled on this browser, please enable them to open this website
2D Array - DS
You are viewing a single comment's thread. Return to all comments →
My Java 8 Solution: