You will be given a two-dimensional array and a number and you are asked to find whether the given matrix is Toeplitz or not. A matrix is a Toeplitz matrix if every descending diagonal, going from left to right, has only one distinct element. That is, it should be in the form:
Input Format:
You will be given a function which will take two-dimensional
matrix as argument.
Output Format:
Return 1
from the function if the matrix is Toeplitz, else return -1
.
Constraints:
3 < n,m < 10,000,000
where n
is the number of rows while m
will be the number of columns.
Sample Test Case:
Sample Input :
4
5
6 7 8 9 2
4 6 7 8 9
1 4 6 7 8
0 1 4 6 7
Sample Output :
1
Scoring
This is code-golf, so the shortest answer in bytes wins.