forked from Coding-Cartel/GeeksforGeeks_all_DSA_problems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboolean_matrix.cpp
29 lines (29 loc) · 896 Bytes
/
boolean_matrix.cpp
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
class Solution
{
public:
// Function to modify the matrix such that if a matrix cell matrix[i][j]
// is 1 then all the cells in its ith row and jth column will become 1.
void booleanMatrix(vector<vector<int>> &matrix)
{
// code here
vector<vector<int>> matrix2 = matrix;
for (int i = 0; i < matrix2.size(); i++)
{
for (int j = 0; j < matrix2[0].size(); j++)
{
if (matrix2[i][j] == 1)
{
for (int k = 0; k < matrix.size(); k++)
{
matrix[k][j] = 1;
}
for (int l = 0; l < matrix[0].size(); l++)
{
matrix[i][l] = 1;
}
}
}
}
}
};reverse(temp.begin(),temp.end());
ans.append(temp);