← previousnext →
Problem
Return the sum of all elements on the outer border of a non-empty rectangular grid (each border cell counted once).
Examples
borderSum([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) -> 40borderSum([[5, 1], [2, 3]]) -> 11
Return the sum of all elements on the outer border of a non-empty rectangular grid (each border cell counted once).
borderSum([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) -> 40borderSum([[5, 1], [2, 3]]) -> 11