We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0d72884 commit cb476d7Copy full SHA for cb476d7
2D Arrays/Set Matrix Zero.cpp
@@ -0,0 +1,27 @@
1
+class Solution {
2
+public:
3
+ void setZeroes(vector<vector<int>>& m) {
4
+ set<int>row,col;
5
+
6
+ for(int i=0;i<m.size();i++){
7
+ for(int j=0;j<m[0].size();j++){
8
+ if(m[i][j]==0){
9
+ row.insert(i);
10
+ col.insert(j);
11
+ }
12
13
14
15
16
+ for(auto it=row.begin();it!=row.end();it++){
17
18
+ m[*it][j]=0;
19
20
21
22
+ for(auto it=col.begin();it!=col.end();it++){
23
+ for(int j=0;j<m.size();j++){
24
+ m[j][*it]=0;
25
26
27
0 commit comments