Last active
May 12, 2017 19:54
-
-
Save Se7soz/8414317 to your computer and use it in GitHub Desktop.
Read the How to prepare for an interview series at my blog: http://se7so.blogspot.com/2014/01/how-to-prepare-for-interview.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void resetMtrx(vector<vector<int> >& mtrx) { | |
| if(mtrx.size() == 0 || mtrx[0].size() == 0) return; | |
| int rows[mtrx.size()], cols[mtrx[0].size()]; | |
| memset(rows, 1, sizeof rows); | |
| memset(cols, 1, sizeof cols); | |
| for(int i = 0; i < mtrx.size(); i++) { | |
| for(int j = 0; j < mtrx[i].size(); j++) { | |
| if(mtrx[i][j] == 0) { | |
| rows[i] = cols[j] = 0; | |
| } | |
| } | |
| } | |
| for(int i = 0; i < mtrx.size(); i++) | |
| for(int j = 0; j < mtrx[i].size(); j++) | |
| if(rows[i] || cols[j]) mtrx[i][j] = '0'; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment