You are viewing a single comment's thread. Return to all comments →
My efficient java solution
private static void printLargestSumOfHourglasses(List<List<Integer>> arr) { int result = -63; for (int row = 0; row < 4; row++) { for (int col = 0; col < 4; col++) { int current = 0; current += arr.get(row).subList(col, col + 3).stream().mapToInt(x -> x).sum(); current += arr.get(row + 1).get(col + 1); current += arr.get(row + 2).subList(col, col + 3).stream().mapToInt(x -> x).sum(); result = Math.max(result, current); } } System.out.println(result); }
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 →
My efficient java solution