You are viewing a single comment's thread. Return to all comments →
public static int hourglassSum(List<List<int>> arr) { int sum=0; int max = 0; int f =1; for(var i=1; i<5;i++) { for(var j=1; j<5;j++) { sum = arr[i][j] + arr[i-1][j-1]+arr[i-1][j]+arr[i-1][j+1] +arr[i+1][j-1]+arr[i+1][j]+arr[i+1][j+1]; if( f==1) { max = sum; f = 0; } if(max < sum) 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 →