Find the sum of all the elements in the matrix which do not lie at the border
Description
You are given a matrix A of size N X M. Find the sum of all the elements in the matrix which do not lie at the border.
Input
The first line of the input contains N and M, denoting the dimensions of the matrix.
The next N lines contain M space separated integers each, denoting the elements of the matrix.
Constraints
1 <= N, M <= 100
1 <= A[i][j] <= 100
Output
Print a single integer denoting the sum of all the elements in the matrix, which do not lie at the border.
Hint
In the sample test case, the elements which do not lie at the border, are {6,7,10,11}. Therefore, the sum of the elements are => 6 + 7 + 10 + 11 = 34, which is the required answer.
Comments
Post a Comment