You are viewing a single comment's thread. Return to all comments →
here's a method much cleaner for List input
private static int printMaxSum(List<List<Integer>> matrix){ int ans=Integer.MIN_VALUE; for(int i=0;i<=3;i++){ List<Integer> row1 = matrix.get(i); List<Integer> row2 = matrix.get(i+1); List<Integer> row3 = matrix.get(i+2); for(int j=0; j<=3;j++){ int sum=row1.get(j+0)+row1.get(j+1)+row1.get(j+2) +row2.get(j+1)+row3.get(j+0)+row3.get(j+1)+row3.get(j+2); if(sum>ans) ans=sum; } } return ans; }
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.
Java 2D Array
You are viewing a single comment's thread. Return to all comments →
here's a method much cleaner for List input