2133. Check if Every Row and Column Contains All Numbers
2022. 1. 9. 16:31ㆍAlgorithm/Leetcode, Lintcode, HackerRank, etc.
- 목차
반응형
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
반응형
'Algorithm > Leetcode, Lintcode, HackerRank, etc.' 카테고리의 다른 글
2244. Minimum Rounds to Complete All Tasks (0) | 2022.05.01 |
---|---|
2243. Calculate Digit Sum of a String (0) | 2022.04.29 |
2248. Intersection of Multiple Arrays (0) | 2022.04.29 |
2138. Divide a String Into Groups of Size k (0) | 2022.01.22 |
2134. Minimum Swaps to Group All 1's Together II (0) | 2022.01.09 |