Skip to content

#2352 - Equal Row and Column Pairs

MediumHash Map / Set
Open on LeetCode

Given a 0-indexed n × n integer matrix grid, return the number of pairs (ri, cj) such that row i and column j are equal (same elements in the same order).

InputOutput
grid = [[3,2,1],[1,7,6],[2,7,7]]1
grid = [[3,1,2,2],[1,4,4,5],[2,4,2,2],[2,4,2,2]]3

Released under the MIT License.