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
PostgreSQLv16

Čia bus kodo vykdymo rezultatas

Visible tests
1
Input
[[1,2,3,4],[5,1,2,3],[9,5,1,2]]
ExpectedTrue
2
Input
[[1,2],[2,2]]
ExpectedFalse
3
Input
[[1]]
ExpectedTrue
4
Input
[[1,2,3],[4,1,2],[5,4,1]]
ExpectedTrue
5
Input
[[1,2],[3,1],[4,3],[5,4]]
ExpectedTrue
6
Input
[[1,2],[3,1],[4,3],[5,4],[1,2]]
ExpectedFalse
Focus radio
Paused · SomaFM · Fluid