Matching Diagonals
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]]Вывод
TrueНужно реализовать
def is_toeplitz(matrix: list[list[int]]) -> bool:
Теги
arraymath
Log ind for at se indsendelseshistorik
Log indLog ind for at bruge AI-mentor
Log indVisible tests
1
Input
[[1,2,3,4],[5,1,2,3],[9,5,1,2]]Expected
True2
Input
[[1,2],[2,2]]Expected
False3
Input
[[1]]Expected
True4
Input
[[1,2,3],[4,1,2],[5,4,1]]Expected
True5
Input
[[1,2],[3,1],[4,3],[5,4]]Expected
True6
Input
[[1,2],[3,1],[4,3],[5,4],[1,2]]Expected
FalseFocus radio
Paused · SomaFM · Fluid