Boolean matrix segmentation

question–>
https://practice.geeksforgeeks.org/problems/boolean-matrix-problem-1587115620/1/?track=md-arrays&batchId=144#
code–>

what is your logic in this question??

you are check only first row or first col
if (mat[0][j] == 1 || mat[i][0] == 1) {

Correct approach of this problem

see the solution
make a dry run first try to understand
if have any doubt feel free to ask

hi i am trying to use the first col and row itself without using auxillary array or vector instead of using another array that’s why i am using a flag to see that if first column and row have one in them
i sent the wrong code
this is the code–>

code is correct only mistake is
at line no 9
for(int j=0;matrix[0].size();j++){
correct statement is
for(int j=0;j<matrix[0].size();j++){

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.