Close
Topic list
Toeplitz Matrix
EASY
25 mins
Matrices (2D Arrays)
Topics (Covered in this problem)
Problem solved
Skill meter
Matrices (2D Arrays)
-
-
Other topics
Problem solved
Skill meter
Strings
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Toeplitz Matrix

Contributed by
srejanbera
Easy
0/40
Avg time to solve 25 mins
Success Rate 80 %
Share

## Problem Statement

#### You are given the matrix ‘MAT’ of size N * M.Your task is to find out whether it is Toeplitz or not.

##### For Example
`````` The given matrix is Toeplitz:
``````

Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1:
``````2
3 3
2 1 3
1 2 1
5 1 2
4 3
0 0 0
7 0 1
1 7 0
0 1 7
``````
##### Sample Output 1:
``````YES
NO
``````
##### Explanation of sample input 1:
``````For the first test case,
``````

``````All the diagonals of the given matrix has same values.Hence, the given matrix is Toeplitz.

For the second test case:
The diagonal with cells (0,1) and  (1,2) does not have the same elements. Hence, the matrix is not Toeplitz.
``````
##### Sample Input 2:
``````2
4 3
10 10 10
4 10 10
2 10 10
4 4 8
3 4
5 10 4 10
5 5 10 4
9 5 5 10
``````
##### Sample Output 2:
``````NO
YES
``````
Auto
Console