Leetcode 73
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的更多相关文章
- LeetCode 73,为什么第一反应想到的解法很有可能是个坑?
本文始发于个人公众号:TechFlow,原创不易,求个关注 今天是LeetCode第42篇文章,我们来看看LeetCode第73题矩阵置零,set matrix zeroes. 这题的难度是Mediu ...
- Java实现 LeetCode 73 矩阵置零
73. 矩阵置零 给定一个 m x n 的矩阵,如果一个元素为 0,则将其所在行和列的所有元素都设为 0.请使用原地算法. 示例 1: 输入: [ [1,1,1], [1,0,1], [1,1,1] ...
- 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 ...
- [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 ...
- Leetcode#73 Set Matrix Zeroes
原题地址 用矩形的第一行和第一列充当mask 代码: void setZeroes(vector<vector<int> > &matrix) { ].empty()) ...
- [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 ...
- leetcode[73] Set Matrix Zeroes 将矩阵置零
给定一个矩阵,把零值所在的行和列都置为零.例如: 1 2 3 1 3 1 1 1 操作之后变为 1 3 0 0 0 1 1 方法1: 赋值另存一个m*n的矩阵,在原矩阵为零的值相应置新的矩阵行和列为零 ...
- leetcode 73 矩阵置零 Python
矩阵置零 给定一个 m x n 的矩阵,如果一个元素为 0,则将其所在行和列的所有元素都设为 0.请使用原地算法. 示例 1: 输入: [ [1,1,1], [1,0,1], [1 ...
- LeetCode 73. 矩阵置零(Set Matrix Zeroes)
题目描述 给定一个 m x n 的矩阵,如果一个元素为 0,则将其所在行和列的所有元素都设为 0.请使用原地算法. 示例 1: 输入: [ [1,1,1], [1,0,1], [1,1,1 ...
随机推荐
- iOS开发之AFNetworking实现数据传输和文件上传
//传输数据 1 AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.r ...
- mysql5.7密码设置
mysql5.7版本引入了强制更改密码的举措,只能吐槽一句,shit!mysql5.7安装安装完mysql之后,mysql已经随机指定了一个初始化密码,可以在mysql的错误日志中找到初始化密码: c ...
- Non-resolvable parent POM
今天导入公司项目,maven聚合项目,但是项目目录结构不正确,内层的项目的parent不是外层项目,这个......有点无语,结果导入直接报错.同事说,我们导入是好好的啊,原来他们用的是eclipse ...
- STM32.SPI(25Q16)
1.首先认识下W25Q16DVSIG, SOP8 SPI FLASH 16MBIT 2MB(4096个字节) (里面可以放字库,图片,也可以程序掉电不丢失数据放里面) 例程讲解: ① 1.用到SPI ...
- ubuntu16.04下内核模块解析
一.环境如下: 1.1内核版本: jello@jello:~$ uname -a Linux jello 4.4.0-89-generic #112-Ubuntu SMP Mon Jul 31 19: ...
- [codeWars] - 8kyu的简单复习
https://www.codewars.com/kata/5aa736a455f906981800360d public class Kata { public static boolean fea ...
- 在线js编程网站 精品版
https://jsfiddle.net/ 引自:http://www.ykmimi.com/tools.html
- BZOJ 1005: [HNOI2008]明明的烦恼(prufer数列)
http://www.lydsy.com/JudgeOnline/problem.php?id=1005 题意: Description 自从明明学了树的结构,就对奇怪的树产生了兴趣......给出标 ...
- self用法
- hdu 1014 Uniform Generator 数论
摘取于http://blog.csdn.net/kenden23/article/details/37519883: 找到规律之后本题就是水题了,不过找规律也不太容易的,证明这个规律成立更加不容易. ...