We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2de2836 commit 19aabb3Copy full SHA for 19aabb3
HackerRank/DiagonalDifference.java
@@ -0,0 +1,25 @@
1
+package com.saintech.allprogtutorials.hackerrank.algos;
2
+
3
+import java.util.Scanner;
4
5
+/**
6
+ * @author Sain Technology Solutions
7
+ *
8
+ * Solution to Problem - https://www.hackerrank.com/challenges/diagonal-difference
9
+ */
10
+public class DiagonalDifference {
11
12
+ public static void main(String[] args) {
13
+ Scanner in = new Scanner(System.in);
14
+ final int N = Integer.parseInt(in.nextLine());
15
+ long diff = 0;
16
+ for(int i=0; i < N; i++) {
17
+ String[] row = in.nextLine().split(" ");
18
+ diff += (Integer.parseInt(row[i]) - Integer.parseInt(row[N - 1 - i]));
19
+ }
20
21
+ System.out.println(Math.abs(diff));
22
23
+ in.close();
24
25
+}
0 commit comments