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.
.publicstaticinthourglassSum(List<List<Integer>>arr){// Write your code hereintmaxSum=-9999;for(inti=0;i<4;i++){for(intj=0;j<4;j++){intcurrentSum=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(currentSum>maxSum){maxSum=currentSum;}}}returnmaxSum;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
2D Array - DS
You are viewing a single comment's thread. Return to all comments →