Skip to content

Latest commit

 

History

History
46 lines (32 loc) · 1.2 KB

_2352. Equal Row and Column Pairs.md

File metadata and controls

46 lines (32 loc) · 1.2 KB

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : June 27, 2024

Last updated : June 27, 2024


Related Topics : Array, Hash Table, Matrix, Simulation

Acceptance Rate : 70.32 %


Solutions

Python

class Solution:
    def equalPairs(self, grid: List[List[int]]) -> int:
        horizontal = {}
        vertical = {}

        for i, row in enumerate(grid) :
            horizontal[i] = tuple(row)
        
        for j in range(len(grid[0])) :
            vertical[j] = tuple([grid[i][j] for i in range(len(grid))])
        
        output = 0
        for i in range(len(grid)) :
            for j in range(len(grid[0])) :
                if horizontal[i] == vertical[j] :
                    output += 1

        return output