Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public void setZeroes(int[][] matrix) {
- int n=matrix.length;
- int m=matrix[0].length;
- int row[]=new int[n];
- int column[]=new int[m];
- for(int i=0;i<n;i++){
- for(int j=0;j<m;j++){
- if(matrix[i][j]==0){
- row[i]=1;
- column[j]=1;
- }
- }
- }
- for(int i=0;i<n;i++){
- for(int j=0;j<m;j++){
- if(row[i]==1 || column[j]==1) matrix[i][j]=0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement