You are viewing a single comment's thread. Return to all comments →
from itertools import product def hourglassSum(arr): center_cp = list(product(range(1, 5), repeat=2)) rel_x, rel_y = [-1, 0, 1], [-1, 1] rel_cp = list(product(rel_x, rel_y)) sums = [] for x, y in center_cp: summ = arr[y][x] for i, j in rel_cp: summ += arr[y+j][x+i] sums.append(summ) return max(sums)
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 →