2133. Check if Every Row and Column Contains All Numbers
class Solution: def checkValid(self, matrix: List[List[int]]) -> bool: n = len(matrix) for y in range(n): cnts = [0]*n for x in range(n): cnts[matrix[y][x] - 1] += 1 if cnts != [1]*n: return False for x in range(n): cnts = [0]*n for y in range(n): cnts[matrix[y][x] - 1] += 1 if cnts != [1]*n: return False return True
2022.01.09