Se încarcă problema…
In a Toeplitz matrix, every diagonal going from top-left to bottom-right contains the same value. Given a matrix matrix, check whether this rule holds for all such diagonals. Return True if it does, otherwise return False.
[[1, 2, 3, 4], [5, 1, 2, 3], [9, 5, 1, 2]]True[[1, 2], [2, 2]]False[[1]]Truedef is_toeplitz(matrix: list[list[int]]) -> bool:
Conectează-te pentru a vedea istoricul soluțiilor trimise
Conectează-teConectează-te pentru a folosi Mentorul AI
Conectează-te[[1,2,3,4],[5,1,2,3],[9,5,1,2]]True[[1,2],[2,2]]False[[1]]True[[1,2,3],[4,1,2],[5,4,1]]True[[1,2],[3,1],[4,3],[5,4]]True[[1,2],[3,1],[4,3],[5,4],[1,2]]False