Google Meta Amazon Coding Interview Question – Toeplitz Matrix

Join me to stay up-to-date and get my new articles delivered to your inbox by subscribing here.

March 22, 2022

Amazon Interview  Coding & Algorithm Interview  Google Interview  Meta Interview 

Given a matrix in the form (int height, int weight, vector < vector < int > > matrix), determine if the matrix is in the form of Toeplitz.

In linear algebra, a Toeplitz matrix or diagonal-constant matrix, named after Otto Toeplitz, is a matrix in which each descending diagonal from left to right is constant.

For more information, click here.

bool is_toeplitz(const int &height, const int &width, const vector < vector < int > > &matrix)
 for(int i = 1 ; i < height ; i++)
  for(int  j = 1 ; j < width ; j++)
   if (matrix[i][j] != matrix[i-1][j-1]) return false;

 return true;