-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSolution.java
More file actions
30 lines (29 loc) · 770 Bytes
/
Copy pathSolution.java
File metadata and controls
30 lines (29 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public class Solution
{
public void setZeroes(int[][] matrix)
{
boolean[] flipRow = new boolean[matrix.length];
boolean[] flipCol = new boolean[matrix[0].length];
for (int i = 0; i < matrix.length; i++)
{
for (int j = 0; j < matrix[0].length; j++)
{
if (matrix[i][j] == 0)
{
flipRow[i] = true;
flipCol[j] = true;
}
}
}
for (int i = 0; i < matrix.length; i++)
{
for (int j = 0; j < matrix[0].length; j++)
{
if (flipRow[i] || flipCol[j])
{
matrix[i][j] = 0;
}
}
}
}
}