Toeplitz Matrix
Is the matrix Toeplitz — constant along every top-left-to-bottom-right diagonal?
Input: the first line has N and M; the next N lines each have M integers.
Output: YES or NO.
Constraints:
- 1 ≤ N, M ≤ 100
Sample Tests
Input 1
3 4 1 2 3 4 5 1 2 3 9 5 1 2
Output 1
YES
Input 2
2 2 1 2 2 2
Output 2
NO
Discussion (opens after you solve — no spoilers before)
No comments yet.