how abt this: if(!a[0][0]) { first traverse the 1st row till we find 1. if dere is 1.... do a[0][0]+=2; then traverse the first column till 1.. if dere is 1... do a[0][0]+=3; }
apply dave's method if(a[0][0]==2) make 1st row 1.... else if(a[0][0]==3) make 1st column 1... else if(a[0][0]==5 || a[0][0]==1) make both 1st row and col 1... On Sep 2, 12:32 pm, kranthi raj <kranthi...@gmail.com> wrote: > oops missed Space Complexity > > > > > > On Fri, Sep 2, 2011 at 12:55 PM, kranthi raj <kranthi...@gmail.com> wrote: > > for( i = 0 ; i < n ; ++i ) > > for( j = 0 ; j < m ; ++j ) > > if( a[i][j] != 0 ) > > row[j]=col[i]=1; > > > for( i = 0 ; i < n ; ++i ) > > for( j = 0 ; j < m ; ++j ) > > > { > > if (row[j]==1 || col[i]==1) > > a[i][j]=1; > > } > > > Does this work? > > -- > Sincerely, > Kranthi Raj A > 2nd Mtech > Dept Of Computer Science , > Indian Institute of Technology, Madras > > #9884989577begin_of_the_skype_highlighting 9884989577 end_of_the_skype_highlighting -- 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.