class Solution {
public:
void setZeroes(vector<vector<int> > &matrix) {
int row[matrix.size()], col[matrix[0].size()];
for( int i = 0 ; i < matrix.size() ; i++ ) {
row[i] = 1;
}
for( int i = 0 ; i < matrix[0].size() ; i++ ) {
col[i] = 1;
}
for( int i = 0 ; i < matrix.size() ; i++ ) {
for( int j = 0 ; j < matrix[i].size() ; j++ ) {
if( matrix[i][j] == 0 ) {
row[i] = 0;
col[j] = 0;
}
}
}
for( int i = 0 ; i < matrix.size() ; i++ ) {
for( int j = 0 ; j < matrix[i].size() ; j++ ) {
if( row[i] == 0 || col[j] == 0 ) {
matrix[i][j] = 0;
}
}
}
}
};
System Design for Beginners
A masterclass that helps early engineers and product managers become great at designing scalable systems.
132+ learners
Details →System Design Masterclass
A masterclass that helps you become great at designing scalable, fault-tolerant, and highly available systems.
1000+ learners
Details →Redis Internals
Learn internals of Redis by re-implementing some of the core features in Golang.
98+ learners
Details →