Created
November 29, 2019 22:48
-
-
Save romanoffs/f0b68d833e4977d2ce225fc2531e9718 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int diagonalDifference(int size, List<List<Integer>> arr) { | |
int sum1, sum2; | |
sum1 = IntStream | |
.range(0, size) | |
.map(i -> arr.get(i).get(i)) | |
.sum(); | |
sum2 = IntStream | |
.range(0, size) | |
.map(i -> arr.get(i).get((size - 1) - i)) | |
.sum(); | |
return Math.abs(sum1 - sum2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment