• + 1 comment

    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
    }