# Algorithms—73.Set Matrix Zeroes

public class Solution {
public void setZeroes(int[][] matrix) {
boolean f=true;
for (int i = 0; i < matrix.length; i++) {
if (matrix[i][0]==0) {
f=false;
break;
}
}
boolean l=true;
for (int i = 0; i < matrix[0].length; i++) {
if (matrix[0][i]==0) {
l=false;
}
}
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
if (matrix[i][j]==0) {
matrix[i][0]=0;
matrix[0][j]=0;
}
}
}
for (int i = 1; i < matrix.length; i++) {
for (int j = 1; j < matrix[i].length; j++) {
if (matrix[i][0]==0||matrix[0][j]==0) {
matrix[i][j]=0;
}
}
}
if (!f) {
for (int i = 0; i < matrix.length; i++) {
matrix[i][0]=0;
}
}
if (!l) {
for (int i = 0; i < matrix[0].length; i++) {
matrix[0][i]=0;
}
}
}
}

#### leetcode_question_73 Set Matrix Zeroes

2013-09-19 21:47:44

#### LeetCode 73 — Set Matrix Zeroes（C++ Java Python）

2014-04-01 18:27:43

#### [leetcode] 【数组】73. Set Matrix Zeroes

2016-05-28 11:42:42

#### leetcode - 73.Set Matrix Zeroes

2017-03-13 13:44:21

#### [LeetCode]73.Set Matrix Zeroes

2014-01-23 20:45:33

#### 【LeetCode】Set Matrix Zeroes 解题报告

2014-10-24 10:17:51

#### LeetCode --- 73. Set Matrix Zeroes

2015-03-20 21:50:38

#### 73.Set Matrix Zeroes

2015-06-27 11:26:51

#### [leetcode] 73.Set Matrix Zeroes

2015-06-02 17:28:53

#### Leetcode：73.Set Matrix Zeroes

2017-11-29 10:50:26