PEC-CSS / Open-Source

Official ACM CSS PEC repository for resources and all things Open source
86 stars 132 forks source link

Toeplitz Matrix #364

Closed ultimatecoder2 closed 3 years ago

ultimatecoder2 commented 3 years ago

Given a two-dimensional matrix of integers matrix, determine whether it's a Toeplitz matrix. A Toeplitz is one where every diagonal descending from left to right has the same value.

Constraints

n, m ≤ 250 where n and m are the number of rows and columns in matrix

Sample Test Case 1

INPUT: matrix = [ [0, 1, 2], [3, 0, 1], [4, 3, 0], [5, 4, 3] ]

OUTPUT: True

Sample Test Case2

INPUT: matrix = [ [1, 0, 0], [0, 0, 0], [0, 0, 1] ]

OUTPUT: False