Problem
Given an n x n integer grid, return the number of pairs (r, c) such that row `r` and column `c` are equal: they contain the same values in the same order (column read from top to bottom).
Example 1
grid = [[3, 2, 1],
Example 2
[1, 7, 6],
Example 3
- Input
- [2, 7, 7]]
- Output
- 1
- Why
- row 2 equals column 1: [2, 7, 7]
Example 4
grid = [[1, 1],
Example 5
- Input
- [1, 1]]
- Output
- 4
- Why
- every row equals every column
Constraints
n == grid.length == grid[i].length1 <= n <= 2001 <= grid[i][j] <= 10^5