You are viewing a single comment's thread. Return to all comments →
let hourGlassArr = [] for (let i=1; i<arr.length -1; i++) { for (let j=1; j<arr[i].length -1; j++){ let upperSum = 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] + arr[i][j] hourGlassArr.push(upperSum) } } return hourGlassArr.reduce((pr, cr) => cr > pr ? cr : pr)
2D Array - DS
You are viewing a single comment's thread. Return to all comments →