You are viewing a single comment's thread. Return to all comments →
c#
public static int hourglassSum(List> arr) { int max=Int32.MaxValue*-1;
for(int v=0;v<4;v++){ for(int h=0;h<4;h++){ int sum = 0; sum += arr[v][h] + arr[v][h+1] + arr[v][h+2]; sum += arr[v+1][h+1]; sum += arr[v+2][h] + arr[v+2][h+1] + arr[v+2][h+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 →
c#
public static int hourglassSum(List> arr) { int max=Int32.MaxValue*-1;