Skip to content

Practice Equal Row and Column Pairs

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2352
LeetCode Problem

Equal Row and Column Pairs

Problem Statement

Given a 0-indexed n x n integer matrix grid, return the number of pairs (ri, cj) such that row ri and column cj are equal. A row and column pair is considered equal if they contain the same elements in the same order (i.e., an equal array).

Source: Equal Row and Column Pairs on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
grid = [[3,2,1],[1,7,6],[2,7,7]]
Output
1

# Example 2

Input
grid = [[3,1,2,2],[1,4,4,5],[2,4,2,2],[2,4,2,2]]
Output
3

Constraints

n == grid.length == grid[i].length
1 <= n <= 200
1 <= grid[i][j] <= 10^5

Related LeetCode Problems

Practice more problems similar to Equal Row and Column Pairs.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.