Skip to content

Latest commit

 

History

History
20 lines (15 loc) · 568 Bytes

2352. Equal Row and Column Pairs.md

File metadata and controls

20 lines (15 loc) · 568 Bytes
class Solution:
    def equalPairs(self, grid: List[List[int]]) -> int:

        c=[]
        for i in range(len(grid)):
            l=[]            
            for j in range(len(grid[i])):
                l.append(grid[j][i])    #varying the row in grid to get all column elements
            
            c.append(l)                 #appending column

        res=0
        for i in grid:
            if i in c:                  #i: column element
                res=res+c.count(i)      #not res+1 since multiple i's might be present

        return res