Tap here to switch tabs
Problem
Ask
Submissions

Problem: Toeplitz Matrix

easy
15 min
Understand how to verify whether every diagonal in a matrix contains identical elements, identifying it as a Toeplitz matrix. Explore strategies for efficient matrix traversal and solving the problem even with memory constraints, such as loading only rows or partial rows at a time.

Statement

Given an m×nm \times n matrix, determine whether it is a Toeplitz matrix. Return TRUE if it is, otherwise return FALSE.

A matrix is considered Toeplitz if every diagonal running from the top left to the bottom right contains identical elements. In other words, for every cell matrix[i][j], if both i + 1 and j + 1 are within bounds, then matrix[i][j] must equal matrix[i+1][j+1].

Note:

  • What if the matrix is stored on disk and memory is limited such that you can only load at most one row of the matrix into memory at a time?

  • What if the matrix is so large that you can only load a partial row into memory at once?

Constraints:

  • mm ==== matrix.length

  • nn ==== matrix[i].length

  • 11 \leq mm, nn 20\leq 20

  • 00 \leq matrix[i][j] 99\leq 99

Tap here to switch tabs
Problem
Ask
Submissions

Problem: Toeplitz Matrix

easy
15 min
Understand how to verify whether every diagonal in a matrix contains identical elements, identifying it as a Toeplitz matrix. Explore strategies for efficient matrix traversal and solving the problem even with memory constraints, such as loading only rows or partial rows at a time.

Statement

Given an m×nm \times n matrix, determine whether it is a Toeplitz matrix. Return TRUE if it is, otherwise return FALSE.

A matrix is considered Toeplitz if every diagonal running from the top left to the bottom right contains identical elements. In other words, for every cell matrix[i][j], if both i + 1 and j + 1 are within bounds, then matrix[i][j] must equal matrix[i+1][j+1].

Note:

  • What if the matrix is stored on disk and memory is limited such that you can only load at most one row of the matrix into memory at a time?

  • What if the matrix is so large that you can only load a partial row into memory at once?

Constraints:

  • mm ==== matrix.length

  • nn ==== matrix[i].length

  • 11 \leq mm, nn 20\leq 20

  • 00 \leq matrix[i][j] 99\leq 99