23.06.13 Today’s Leetcode
2352. Equal Row and Column Pairs (medium)
class Solution:
def equalPairs(self, grid: List[List[int]]) -> int:
n = len(grid)
rows = grid
cols = [[grid[x][y] for x in range(n)] for y in range(n)]
# print(rows)
# print(cols)
count = 0
for i in range(n):
for j in range(n):
if cols[i] == rows[j]:
count += 1
return count