leetcode73
public class Solution
{
public void SetZeroes(int[,] matrix)
{
var row = matrix.GetLength();
var col = matrix.GetLength();
var listrow = new Dictionary<int, int>();
var listcol = new Dictionary<int, int>();
for (int i = ; i < row; i++)
{
for (int j = ; j < col; j++)
{
if (matrix[i, j] == )
{
if (!listrow.ContainsKey(i))
{
listrow.Add(i, );
}
if (!listcol.ContainsKey(j))
{
listcol.Add(j, );
}
}
}
}
foreach (var l in listrow)
{
for (int j = ; j < col; j++)
{
matrix[l.Key, j] = ;
}
}
foreach (var l in listcol)
{
for (int i = ; i < row; i++)
{
matrix[i, l.Key] = ;
}
}
}
}
leetcode73的更多相关文章
- 【leetcode73】经典算法-Guess Number Higher or Lower
题目描述: 从1-n中,随便的拿出一个数字,你来猜测. 提示 提供一个guess(int num)的api,针对猜测的数字,返回三个数值.0,-1,1 0;猜中返回num -1:比猜测的数值小 1:比 ...
- [Swift]LeetCode73. 矩阵置零 | 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】 矩阵置零
给定一个 m x n 的矩阵,如果一个元素为 0,则将其所在行和列的所有元素都设为 0.请使用原地算法. 示例 1: 输入: [ [1,1,1], [1,0,1], [1,1,1] ] 输 ...
- leetcode73矩阵置零
https://leetcode-cn.com/problems/set-matrix-zeroes/ 解答: 两种方法时间复杂度都为O(mn) O(m+n)空间方法: 用两个容器储存为0的行和列 c ...
- Leetcode73. Set Matrix Zeroes矩阵置零
给定一个 m x n 的矩阵,如果一个元素为 0,则将其所在行和列的所有元素都设为 0.请使用原地算法. 示例 1: 输入: [ [1,1,1], [1,0,1], [1,1,1] ] 输 ...
- LeetCode73 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.(Me ...
- leetcode73:minmum-window-substring
题目描述 给出两个字符串S和T,要求在O(n)的时间复杂度内在S中找出最短的包含T中所有字符的子串. 例如: S ="ADOBECODEBANC" T ="ABC&quo ...
- leetcode探索中级算法
leetcode探索中级答案汇总: https://leetcode-cn.com/explore/interview/card/top-interview-questions-medium/ 1)数 ...
随机推荐
- java日志体系的思考(转)
Java 日志缓存机制的实现 Java 日志管理最佳实践 混乱的 Java 日志体系 log日志远程统一记录 浅谈后端日志系统 Java异常处理和接口约定 用SLF4j/Logback打印日志-1 用 ...
- IE6开发调试插件:IE Developer Toolbar
下载地址:http://www.microsoft.com/en-us/download/details.aspx?id=18359 1.下载后点击安装 2.安装后重启IE6
- Java语言发展史和eclipse配置
body, table{font-family: 微软雅黑; font-size: 10pt} table{border-collapse: collapse; border: solid gray; ...
- 线程的同步之Synchronized的使用
一.介绍 线程的同步:一般的并发指的就是多个线程访问同一份资源.多个线程同时访问(修改)同一份资源的话,就会有可能造成资源数据有误. 如果多个线程访问多个不同资源,就不会造成线程同 ...
- hibernate的一些缺陷(转)
例如用户在系统中,保存的信息包括简要信息(用户名.联系电话.Email.性别)和一些图像信息(照片). 但是在系统设计时,我的设计方式都是遵循业务的需要,设计一个“用户”类,包含用户名. ...
- tintColor 与 UIImage.renderingMode 渲染
在iOS7中,UIView新增了一个属性tintColor.这是一个UIColor,被使用在UIView中改变应用程序的外观的.默认tintColor的值为nil,这表示它将会运用父视图层次的颜色来进 ...
- STL标准库-hash
技术在于交流.沟通,本文为博主原创文章转载请注明出处并保持作品的完整性 hash的结构图如下图 oject通过hashfunc转换成hashcode然后插入到相应篮子中 hash同rb_tree是一种 ...
- MyBatis的一对一
1. 建立好工程后,在pom.xml中配置myBatis的依赖. <project xmlns="http://maven.apache.org/POM/4.0.0" xml ...
- 解决sublime package control 出现There are no packages available for installation
昨天在安装了一下Sublime Text 3,在安装插件的过程中出现了一些问题,现在记录一下,也给遇到同样问题的朋友一些帮助.在安装插件的时候,需要先安装一下Package Control. 安装Pa ...
- test20181024 hao
题意 分析 考场10分 直接\(O(nm)\)模拟即可. #include<cstdlib> #include<cstdio> #include<cmath> #i ...