• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
June 28, 2024 |450 Views

PROBLEM OF THE DAY : 27/06/2024 | Toeplitz Matrix

Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Ayush Tripathi. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Matrix but also build up problem-solving skills.

A Toeplitz (or diagonal-constant) matrix is a matrix in which each descending diagonal from left to right is constant, i.e., all elements in a diagonal are the same. Given a rectangular matrix mat, your task is to complete the function isToeplitz which returns true if the matrix is Toeplitz otherwise, it returns false.

Examples:

Input:
mat = [[6, 7, 8],
       [4, 6, 7],
       [1, 4, 6]]
Output: true
Explanation: The test case represents a 3x3 matrix
 6 7 8 
4 6 7 
1 4 6
Output will be true, as values in all downward diagonals from left to right contain the same elements.

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/toeplitz-matrix/1