Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5725 |

@blackshadows | 5685 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4908 |

@saiujwal13083 | 4156 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3511 |

@sushant_a | 3453 |

@KshamaGupta | 3318 |

@the_coder95 | 3302 |

Complete Leaderboard | |

Handle | Score |

@avaiesshaik782 | 786 |

@arpitsatnalika | 777 |

@tujhekya | 602 |

@prakharxyz | 601 |

@code_it_ | 591 |

@iamronak | 505 |

@imnm | 500 |

@pradeepkumarjad | 488 |

@satyam0460 | 481 |

@nitesha125 | 480 |

@Rahul Jadhav 1 | 466 |

Complete Leaderboard |

Given a boolean matrix of size RxC where each cell contains either 0 or 1, modify it such that if a matrix cell matrix[i][j] is 1 then all the cells in its i^{th} row and j^{th} column will become 1.

**Example 1:**

Input:R = 2, C = 2 matrix[][] = {{1, 0}, {0, 0}}Output:1 1 1 0Explanation:Only cell that has 1 is at (0,0) so all cells in row 0 are modified to 1 and all cells in column 0 are modified to 1.

**Example 2:**

Input:R = 4, C = 3 matrix[][] = {{ 1, 0, 0}, { 1, 0, 0}, { 1, 0, 0}, { 0, 0, 0}}Output:1 1 1 1 1 1 1 1 1 1 0 0Explanation:The position of cells that have 1 in the original matrix are (0,0), (1,0) and (2,0). Therefore, all cells in row 0,1,2 are and column 0 are modified to 1.

**Your Task:**

You dont need to read input or print anything. Complete the function **booleanMatrix()** that takes the matrix as input parameter and modifies it **in-place**.

**Expected Time Complexity:** O(R * C)

**Expected Auxiliary Space:** O(R + C)

**Constraints:**

1 ≤ R, C ≤ 1000

0 ≤ matrix[i][j] ≤ 1

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Boolean Matrix

...

Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.