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.
/* * Complete the 'hourglassSum' function below. * * The function is expected to return an INTEGER. * The function accepts 2D_INTEGER_ARRAY arr as parameter. */publicstaticinthourglassSum(List<List<Integer>>arr){// Write your code hereintmax=Integer.MIN_VALUE;for(inti=0;i<4;i++){intactual=0;for(intj=0;j<4;j++){actual=arr.get(i).get(j)+arr.get(i).get(j+1)+arr.get(i).get(j+2)+arr.get(i+1).get(j+1)+arr.get(i+2).get(j)+arr.get(i+2).get(j+1)+arr.get(i+2).get(j+2);if(actual>max){max=actual;}}}returnmax;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Join us
Create a HackerRank account
Be part of a 26 million-strong community of developers
Please signup or login in order to view this challenge
2D Array - DS
You are viewing a single comment's thread. Return to all comments →
JAVA