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.
- Prepare
- Data Structures
- Arrays
- 2D Array - DS
- Discussions
2D Array - DS
2D Array - DS
Sort by
recency
|
3646 Discussions
|
Please Login in order to post a comment
Here is my soln in JavaScript. I'm sure that there is a more efficient way to do this, but this was quick and easy.
Haskell
python: def hourglassSum(arr): l=[] for i in range(1,5): for j in range(1,5): l.append(a[i-1][j-1]+a[i-1][j]+a[i-1][j+1]+ a[i][j]+ a[i+1][j-1]+a[i+1][j]+a[i+1][j+1]) return(max(l))
Here is my c++ solution you can watch video explanation here : https://www.youtube.com/watch?v=aJv6KLHL3Qk