首页 > 试题广场 >

清除行列

[编程题]清除行列
  • 热度指数:29200 时间限制:C/C++ 3秒,其他语言6秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解

给定一个N阶方阵int[][](C++中为vector<vector><int>>)mat及其阶数n,若方阵中某个元素为0,则将其所在的行与列清零。返回改变后的int[][]方阵(C++中为vector<vector><int>>),保证n小于等于300,矩阵中的元素在nt范围内。</int></vector></int></vector>

测试样例:
[[1,2,3],[0,1,2],[0,0,1]]
返回:[[0,0,3],[0,0,0],[0,0,0]]
头像 法拉利201903231900848
发表于 2019-08-29 23:41:39
# -*- coding:utf-8 -*- class Clearer:     def clearZero(self, mat, n):      展开全文
头像 Jorunnaparva
发表于 2020-10-07 09:08:50
class Clearer { public: vector<vector<int> > clearZero(vector<vector<int> > mat, int n) { bool fr = any_of(mat[0]. 展开全文
头像 牛客548207004号
发表于 2023-11-09 13:44:42
import java.util.*; public class Clearer { public int[][] clearZero(int[][] mat, int n) { // write code here boolean [] flagh = n 展开全文
头像 清心_恋旧
发表于 2019-07-26 10:47:17
 public int[][] clearZero(int[][] mat, int n) {         // write code here         int[][] result = new i 展开全文
头像 Coming680
发表于 2022-03-24 19:55:36
class Clearer { public: vector<vector<int> > clearZero(vector<vector<int> > mat, int n) { // write code here 展开全文
头像 java的神秘男友script
发表于 2022-01-30 23:29:57
模拟,记录需要清0的行和列(存在col和row中) 然后遍历记录进行清0操作 import java.util.*; public class Clearer { public int[][] clearZero(int[][] mat, int n) { // writ 展开全文
头像 mythwind
发表于 2022-04-11 17:58:02
清除行列,最主要的还是识别行和列,存入列表 public int[][] clearZero(int[][] mat, int n) { HashSet<Integer> setRow = new HashSet<>(); HashSe 展开全文

问题信息

难度:
158条回答 24035浏览

热门推荐

通过挑战的用户

查看代码