@bittu

I am 100% sure, it works fine for any 2D Binary matrix.

========
Algorithm:
========
Step 1: Store matrix [0][0] value in a temporary variable (Space
Complicity: O(1) ).
Step 2: Apply & operation on first column and save it into Temp.
Step 3: Apply & operation on first row and save it into matrix [0][0].
Step 4: Apply & operation on each row and save the result in the first
cell of each row. Here i starts from 1 to n-1.
Step 5: Apply & operation on each column and save the result in the
first cell of each column. Here j starts from 1 to n-1.
Step 6: Now to find the value at matrix[i][j], you have to do a[i][0]
& a[0][j]. Here I and j start from 1 to n-1
Step 7: Now to find the value at matrix [0][i] and matrix[j][0]. If
matrix [0][0] is equal to 0 then make value 0 all the matrix[0][i]
else remain unchanged. If Temp is equal to 0 the make value 0 all the
matrix [j][0] else remain unchanged.
Step 8: Now to find the value at matrix [0][0], you need to do matrix
[0][0] & Temp and save it into matrix [0][0].
Step 9: Print your matrix and exit.

I think, now you will be get all the answers.

Thanks
Yogesh Kumar


On Mar 9, 7:39 pm, bittu <shashank7andr...@gmail.com> wrote:
> @yoku..r u sure..in 2nd last for loop by just setting if (matrix[0]
> [0]==0) e.g. matrix[i][0]=0   and temp=0  e.g. (a[j][0]=0) u r doing
> what asked in question....set a[i][j] or a[j][i] =0  if any a[i] or
> a[j=0 ..i means r u sure that u r not skipping any row or colum
> although u code is working fine....let me know....??
>
> Thanks
> Shashank

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to