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.
I am using Java 8 to sovle this problem. Pls give me answer if you have any questions. Thanks
publicstaticintdiagonalDifference(List<List<Integer>>arr){// Write your code hereintcount=0;intleftToRight=0;intrightToLeft=0;for(inti=0;i<arr.size();i++){intlen=arr.get(i).size();leftToRight+=arr.get(i).get(count);rightToLeft+=arr.get(i).get(len-count-1);count++;}returnMath.abs(leftToRight-rightToLeft);}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Diagonal Difference
You are viewing a single comment's thread. Return to all comments →
I am using Java 8 to sovle this problem. Pls give me answer if you have any questions. Thanks