2319. Check if Matrix Is X-Matrix

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 2319

class Solution:
    def checkXMatrix(self, grid: List[List[int]]) -> bool:
        for i, row in enumerate(grid):
            for j, v in enumerate(row):
                if i == j or i + j == len(grid) - 1:
                    if v == 0:
                        return False
                elif v:
                    return False
        return True