You are given an m × n 2D matrix.
Your task is to determine whether the matrix is a Toeplitz matrix.
A matrix is called Toeplitz if every diagonal from top-left to bottom-right contains the same value.
In other words, for every valid position (i, j), the following must hold:
If all diagonals satisfy this, return true.
Otherwise, return false.
Input: matrix = [[1,2,3,4], [5,1,2,3], [9,5,1,2]]
Output: true
Explanation:
Each diagonal has identical values: [9] [5,5] [1,1,1] [2,2,2] [3,3] [4] So the matrix is Toeplitz.
Input: matrix = [[1,2],[2,2]]
Output: false
Explanation:
The diagonal [1,2] contains different values → not Toeplitz.
Accepted:
Submission: