用暴力做法,遍历每一列,然后遍历所有的行,每当有一个行与该列相同,ans++。
impl Solution {
pub fn equal_pairs(grid: Vec<Vec<i32>>) -> i32
{
let (n, mut col, mut res) = (grid.len(), vec![0; grid.len()], 0);
for i in 0..n
{
for j in 0..n { col[j] = grid[j][i]; }
grid.iter().for_each(|row| if col == *row { res += 1; });
}
res
}
}
标签:mut,相等,..,res,行列,grid,2023.6,col,row
From: https://www.cnblogs.com/st0rmKR/p/17463011.html