Adds best solution

This commit is contained in:
julien Lengrand-Lambert
2017-03-27 19:16:04 +02:00
parent 29c573ef66
commit 6d93a2f162

View File

@@ -0,0 +1,26 @@
package algorithms.DiagonalDifference
import scala.io._
/**
* Created by jll on 3/27/2017.
* Found here : https://codepair.hackerrank.com/paper/X2RXZXPW?b=eyJyb2xlIjoiY2FuZGlkYXRlIiwibmFtZSI6IkFpcmJhbGxtYW4iLCJlbWFpbCI6ImpsZW5ncmFuZEBnbWFpbC5jb20ifQ%3D%3D
*/
class SolutionBest {
def main(args: Array[String]) = {
val size = StdIn.readInt()
var lr: Int = 0
var rl: Int = 0
for(i <- 0 to (size - 1)) {
val rowStr = StdIn.readLine().split(" ")
lr += Integer.parseInt(rowStr(i))
rl += Integer.parseInt(rowStr(size - i - 1))
}
println(Math.abs(lr - rl))
}
}