2352. Equal Row and Column Pairs Medium
1/**
2 * [2352] Equal Row and Column Pairs
3 *
4 * 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.
5 * A row and column pair is considered equal if they contain the same elements in the same order (i.e. an equal array).
6 *
7 * Example 1:
8 * <img alt="" src="https://assets.leetcode.com/uploads/2022/06/01/ex1.jpg" style="width: 150px; height: 153px;" />
9 * Input: grid = [[3,2,1],[1,7,6],[2,7,7]]
10 * Output: 1
11 * Explanation: There is 1 equal row and column pair:
12 * - (Row 2, Column 1): [2,7,7]
13 *
14 * Example 2:
15 * <img alt="" src="https://assets.leetcode.com/uploads/2022/06/01/ex2.jpg" style="width: 200px; height: 209px;" />
16 * Input: grid = [[3,1,2,2],[1,4,4,5],[2,4,2,2],[2,4,2,2]]
17 * Output: 3
18 * Explanation: There are 3 equal row and column pairs:
19 * - (Row 0, Column 0): [3,1,2,2]
20 * - (Row 2, Column 2): [2,4,2,2]
21 * - (Row 3, Column 2): [2,4,2,2]
22 *
23 *
24 * Constraints:
25 *
26 * n == grid.length == grid[i].length
27 * 1 <= n <= 200
28 * 1 <= grid[i][j] <= 10^5
29 *
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/equal-row-and-column-pairs/
34// discuss: https://leetcode.com/problems/equal-row-and-column-pairs/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39 pub fn equal_pairs(grid: Vec<Vec<i32>>) -> i32 {
40 0
41 }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48 use super::*;
49
50 #[test]
51 fn test_2352() {
52 }
53}
54
Back
© 2025 bowen.ge All Rights Reserved.