class Solution {
public:
void setZeroes(vector<vector<int>>& matrix) {
vector<vector<int>> store;
int m = matrix.size();
int n = matrix[].size();
for(int i=;i < m;i++){
for(int j=;j < n;j++){
if(matrix[i][j] == ){
vector<int> temp;
temp.push_back(i);
temp.push_back(j);
store.push_back(temp);
temp.clear();
}
}
}
for(int i=;i < store.size();i++){
int a = store[i][];
int b = store[i][];
for(int j=;j < m;j++) matrix[j][b] = ;
for(int j=;j < n;j++) matrix[a][j] = ;
}
}
};

Leetcode 73的更多相关文章

  1. LeetCode 73,为什么第一反应想到的解法很有可能是个坑?

    本文始发于个人公众号:TechFlow,原创不易,求个关注 今天是LeetCode第42篇文章,我们来看看LeetCode第73题矩阵置零,set matrix zeroes. 这题的难度是Mediu ...

  2. Java实现 LeetCode 73 矩阵置零

    73. 矩阵置零 给定一个 m x n 的矩阵,如果一个元素为 0,则将其所在行和列的所有元素都设为 0.请使用原地算法. 示例 1: 输入: [ [1,1,1], [1,0,1], [1,1,1] ...

  3. LeetCode 73. Set Matrix Zeros(矩阵赋零)

    Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. click ...

  4. [LeetCode] 73. Set Matrix Zeroes 矩阵赋零

    Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Exampl ...

  5. Leetcode#73 Set Matrix Zeroes

    原题地址 用矩形的第一行和第一列充当mask 代码: void setZeroes(vector<vector<int> > &matrix) { ].empty()) ...

  6. [LeetCode] 73. Set Matrix Zeroes 解题思路

    Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. Follow ...

  7. leetcode[73] Set Matrix Zeroes 将矩阵置零

    给定一个矩阵,把零值所在的行和列都置为零.例如: 1 2 3 1 3 1 1 1 操作之后变为 1 3 0 0 0 1 1 方法1: 赋值另存一个m*n的矩阵,在原矩阵为零的值相应置新的矩阵行和列为零 ...

  8. leetcode 73 矩阵置零 Python

    矩阵置零     给定一个 m x n 的矩阵,如果一个元素为 0,则将其所在行和列的所有元素都设为 0.请使用原地算法. 示例 1: 输入: [   [1,1,1],   [1,0,1],   [1 ...

  9. LeetCode 73. 矩阵置零(Set Matrix Zeroes)

    题目描述 给定一个 m x n 的矩阵,如果一个元素为 0,则将其所在行和列的所有元素都设为 0.请使用原地算法. 示例 1: 输入: [   [1,1,1],   [1,0,1],   [1,1,1 ...

随机推荐

  1. nginx 安装手记

    Nginx需要依赖下面3个包 1. gzip 模块需要 zlib 库 ( 下载: http://www.zlib.net/ )  zlib-1.2.8.tar.gz 2. rewrite 模块需要 p ...

  2. [AtCoder ARC061F]Card Game for Three 组合数好题

    题目链接 总结:组合数 这$F$题好难啊...只会部分分做法,下面两个方法都是部分分做法.满分做法我去看看...会的话就补一下 部分分做法 方法1: 首先$A$能赢的条件很明显,假设在所有的牌里面取出 ...

  3. ActiveMQ 负载均衡与高可用(转载)

    一.架构和技术介绍 1.简介 ActiveMQ 是Apache出品,最流行的,能力强劲的开源消息总线.完全支持JMS1.1和J2EE 1.4规范的 JMS Provider实现 2.activemq的 ...

  4. FOJ-1058-粗心的物理学家

    题目:粗心的物理学家 代码: #include<stdlib.h> #include<iostream> #include<cstdio> using namesp ...

  5. LA 3027 合作网络

    https://vjudge.net/problem/UVALive-3027 题意: 有n个结点,初始时每个结点的父节点都不存在.你的任务是执行一次I操作和E操作,格式如下: I u v:把结点u的 ...

  6. windows 模拟用户会话创建进程

    在渗透当中,经常会碰到这样的问题.一个机器,机器上好几个用户,或者域内,想让某个机器的某个会话执行你想要执行的程序,或者中马,以当前会话来上线. 现在模拟如下的一个情况: 严格的DMZ,内网--> ...

  7. MVC ---- EF三层代码

    1.DAL层 using Night.Models; using System; using System.Collections.Generic; using System.Data.Entity. ...

  8. ubuntu16.04上安装Java

    1.下载jdk8 登录网址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 选择 ...

  9. Goroutines和Channels(三)

    clock服务器每一个连接都会起一个goroutine.在本节中我们会创建一个echo服务器,这个服务在每个连接中会有多个goroutine.大多数echo服务仅仅会返回他们读取到的内容,就像下面这个 ...

  10. c++ 容器元素填充指定数量的元素(generate_n)

    #include <iostream> // cout #include <algorithm> // generate_n using namespace std; ; in ...