You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution you can watch video explanation here : https://www.youtube.com/watch?v=aJv6KLHL3Qk
int hourglassSum(vector<vector<int>> arr) { int result = -63; for(int r = 1; r <= 4; r++){ for(int c = 1; c <= 4; c++){ int s = arr[r][c] + arr[r-1][c] + arr[r-1][c-1] + arr[r-1][c+1]; s += arr[r+1][c] + arr[r+1][c-1] + arr[r+1][c+1]; result = max(result,s); } } return result; }
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 →
Here is my c++ solution you can watch video explanation here : https://www.youtube.com/watch?v=aJv6KLHL3Qk