You are viewing a single comment's thread. Return to all comments →
Functional Scala
def diagonalDifference(arr: Array[Array[Int]]): Int = { arr.foldLeft((0, 0, 0))((acc, a) => { val (offset, left, right) = acc (offset + 1, left + a(offset), right + a(a.length - 1 - offset)) }) match { case (_, l, r) => math.abs(l - r) } }
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 →
Functional Scala