You are viewing a single comment's thread. Return to all comments →
int hourglassSum(vector<vector<int>> arr) { vector<int>sums(16); int t=0; for(int i=0;i<16;i++){ int j=i,c=i%4; if(i%4==0&&i!=0)t++; for(int k=c;k<c+3;k++){ sums[j]+=arr[t][k]+arr[t+2][k]; } sums[i]+=arr[t+1][c+1]; } int maxi=INT_MIN; for(int i=0;i<16;i++)if(maxi<sums[i])maxi=sums[i]; return maxi; }
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 →