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 ...
随机推荐
- C_Learning (1)
/数据类型及占用字节 char 1个字节{-128~127} int 2.4个字节,取决于平台是16位还是32位机子{-65536~65535} short int 2个字节{-32768 ...
- ms08_067攻击实验
ms08_067攻击实验 ip地址 开启msfconsole 使用search ms08_067查看相关信息 使用 show payloads ,确定攻击载荷 选择playoad,并查看相关信息 设置 ...
- Tensorflow游乐场
昨天,Google发布了Tensorflow游乐场.Tensorflow是Google今年推出的机器学习开源平台.而有了Tensorflow游乐场,我们在浏览器中就可以训练自己的神经网络,还有酷酷的图 ...
- Linux slab分配器【转】
本文转载自:https://www.ibm.com/developerworks/cn/linux/l-linux-slab-allocator/ 良好的操作系统性能部分依赖于操作系统有效管理资源的能 ...
- linux性能分析工具之火焰图
一.环境 1.1 jello@jello:~$ uname -a Linux jello 4.4.0-98-generic #121-Ubuntu SMP Tue Oct 10 14:24:03 UT ...
- ReentrantReadWriteLock分析
ReentrantReadWriteLock会使用两把锁来解决问题,一个读锁,一个写锁 线程进入读锁的前提条件: 没有其他线程的写锁, 没有写请求或者有读请求,但调用线程和持有锁的线程是同一个 线程进 ...
- 史丰收速算|2014年蓝桥杯B组题解析第四题-fishers
史丰收速算 史丰收速算法的革命性贡献是:从高位算起,预测进位.不需要九九表,彻底颠覆了传统手算! 速算的核心基础是:1位数乘以多位数的乘法. 其中,乘以7是最复杂的,就以它为例. 因为,1/7 是个循 ...
- js中拼接HTML方式方法及注意事项
博主原创:未经博主允许,不得转载 在前端应用中,经常需要在js中动态拼接HTML页面,比如应用ajax进行局部刷新的时候,就需要在js中拼接HTML页面. 主要规则是将HTML页面的标签拼接为标签字符 ...
- The way to Go(7): 变量
参考: Github: Go Github: The way to Go 变量 一般格式:var identifier type. Go在声明变量时将变量的类型放在变量的名称之后: 避免像 C 语言中 ...
- bind9安装配置
BIND的安装配置: dns服务,程序包名叫bind,程序名named 程序包: bind bind-libs bind-utils bind-chroot: /var/named/chroot/ b ...