Class Solution
java.lang.Object
g2301_2400.s2352_equal_row_and_column_pairs.Solution
2352 - Equal Row and Column Pairs.<p>Medium</p>
<p>Given a <strong>0-indexed</strong> <code>n x n</code> integer matrix <code>grid</code>, <em>return the number of pairs</em> <code>(R<sub>i</sub>, C<sub>j</sub>)</code> <em>such that row</em> <code>R<sub>i</sub></code> <em>and column</em> <code>C<sub>j</sub></code> <em>are equal</em>.</p>
<p>A row and column pair is considered equal if they contain the same elements in the same order (i.e. an equal array).</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2022/06/01/ex1.jpg" alt="" /></p>
<p><strong>Input:</strong> grid = [[3,2,1],[1,7,6],[2,7,7]]</p>
<p><strong>Output:</strong> 1</p>
<p><strong>Explanation:</strong> There is 1 equal row and column pair:</p>
<ul>
<li>(Row 2, Column 1): [2,7,7]</li>
</ul>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2022/06/01/ex2.jpg" alt="" /></p>
<p><strong>Input:</strong> grid = [[3,1,2,2],[1,4,4,5],[2,4,2,2],[2,4,2,2]]</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Explanation:</strong> There are 3 equal row and column pairs:</p>
<ul>
<li>
<p>(Row 0, Column 0): [3,1,2,2]</p>
</li>
<li>
<p>(Row 2, Column 2): [2,4,2,2]</p>
</li>
<li>
<p>(Row 3, Column 2): [2,4,2,2]</p>
</li>
</ul>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>n == grid.length == grid[i].length</code></li>
<li><code>1 <= n <= 200</code></li>
<li><code>1 <= grid[i][j] <= 10<sup>5</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
equalPairs
public int equalPairs(int[][] grid)
-