You are viewing a single comment's thread. Return to all comments â†’

I did in javascript here's the code and i think, -infinity would be more plausible to instead of -99999 for maxSum

function hourglassSum(arr) { const row = arr.length const col = arr[0].length let maxSum = -99999 for(let i=0; i<row-2; i++){ for(let j = 0; j<col-2;j++){ let tempSum = arr[i][j] + arr[i][j+1] + arr[i][j+2] + arr[i+1][j+1] + arr[i+2][j] + arr[i+2][j+1] + arr[i+2][j+2] if(tempSum > maxSum){ maxSum = tempSum } } } return maxSum }

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 â†’

I did in

javascripthere's the code and i think,-infinitywould be more plausible to instead of -99999 formaxSum