You are viewing a single comment's thread. Return to all comments →
Javascript: Make sure to understand the question properly. I misunderstood it the first time.
var sum_hourglass_array = []; var sum; //k is vertical //j is horizontal for (let k=0; k<6; k++){ let row = arr[k]; for(let j=0; j<6;j++){ if ((j+2) <=5 && (k+2)<=5){ sum = arr[k][j] + arr[k][j+1] + arr[k][j+2] + arr[k+1][j+1] + arr[k+2][j] + arr[k+2][j+1] + arr[k+2][j+2]; sum_hourglass_array.push(sum); } } } console.log(Math.max.apply(Math,sum_hourglass_array));
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Day 11: 2D Arrays
You are viewing a single comment's thread. Return to all comments →
Javascript: Make sure to understand the question properly. I misunderstood it the first time.