dave s algo is nice :) On Aug 31, 10:09 pm, Dave <dave_and_da...@juno.com> wrote: > @Ashima: Scan all but the first row and the first column. If there is > a 1 in a row, set the first element of that row to 1. If there is a 1 > in a column, set the first element of that column to zero. Now, set > any element in all but the first row and the first column of the > matrix that has a 1 it the first element of its row or a 1 in its > first element of its colunn to 1. > > Dave > > On Aug 31, 12:02 pm, "Ashima ." <ashima.b...@gmail.com> wrote: > > > > > > > > > @dave wats d logic behind ur code > > > Ashima > > M.Sc.(Tech)Information Systems > > 4th year > > BITS Pilani > > Rajasthan > > > On Wed, Aug 31, 2011 at 9:05 AM, Dave <dave_and_da...@juno.com> wrote: > > > @Manish: > > > > for( i = 1 ; i < n ; ++i ) > > > for( j = 1 ; j < m ; ++j ) > > > if( a[i][j] != 0 ) > > > a[i][0] = a[0][j] = 1; > > > for( i = 1 ; i < n ; ++i ) > > > for( j = 1 ; j < m ; ++j ) > > > if( a[i][0] + a[0][j] != 0 ) > > > a[i][j] = 1; > > > > Dave > > > > On Aug 31, 8:40 am, manish kapur <manishkapur.n...@gmail.com> wrote: > > > > Input is a matrix of size n x m of 0s and 1s. > > > > > eg: > > > > 1 0 0 1 > > > > 0 0 1 0 > > > > 0 0 0 0 > > > > > If a location has 1; make all the elements of that row and column = 1. > > > > eg > > > > > 1 1 1 1 > > > > 1 1 1 1 > > > > 1 0 1 1 > > > > > Solution should be with Time complexity = O(n*m) and O(1) extra space > > > > -- > > > 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.-Hide quoted text - > > > - Show quoted text -
-- 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.