We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
sum=arr[i][j+x] -> sums the top row of the hour glass
sum=arr[i+2][j+x] -> sums the bottom row of the hourglass.
sum = arr[i+1][j+1] -> sums the middle row.
arr[1 2 3
4 5 6
7 8 9]
if i=0,j=0,x=0
calculate and increment.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 11: 2D Arrays
You are viewing a single comment's thread. Return to all comments →
sum=arr[i][j+x] -> sums the top row of the hour glass sum=arr[i+2][j+x] -> sums the bottom row of the hourglass. sum = arr[i+1][j+1] -> sums the middle row. arr[1 2 3 4 5 6 7 8 9] if i=0,j=0,x=0 calculate and increment.