plz xplain result after first scaning On Fri, Sep 30, 2011 at 5:05 PM, Ankur Garg <ankurga...@gmail.com> wrote:
> @Rahul > Scan the matrix and whenver u see a[i][j]=0 put a[i]]0]=0 and a[0][j]=0 > > Meaning to say that put that row or column as 0 > > Now, > Scan the first row and first column and whereever u see a 0 make that > column and row 0 respectively > > Eg > > 1 1 1 1 > 0 1 0 1 > 1 1 1 0 > > Answer shud be > > 0 1 0 0 > 0 0 0 0 > 0 0 0 0 > > Scan Array First After Scanning it become > > 0 1 0 0 > 0 1 0 1 > 0 1 1 1 > Now Scan first row and for a[0][j] make a[i][j] 0 > so > > 0 1 0 0 > 0 1 0 0 > 0 1 0 0 > Now scan column ..Remember to start from a[1][0] and a[0][1] > > 0 1 0 0 > 0 0 0 0 > 0 0 0 0 > > Hope it helps > > Ankur > > > On Fri, Sep 30, 2011 at 3:47 PM, rahul sharma <rahul23111...@gmail.com>wrote: > >> provide me with o(1) space ...i need it vey urgent.....can it be >> done...thnx in advance. >> >> >> On Fri, Sep 30, 2011 at 3:44 PM, rahul sharma <rahul23111...@gmail.com>wrote: >> >>> sorry n*m complex where n rows and m col >>> but correct for space pzl and it uses two xtras array row and col >>> >>> >>> On Fri, Sep 30, 2011 at 3:42 PM, rahul sharma >>> <rahul23111...@gmail.com>wrote: >>> >>>> i cant find xact soln on previous thread????i have sol with n*n >>>> complexity but used space,, i.e >>>> >>>> scan whole matrix >>>> if( matrix([i][j]==1) >>>> { >>>> row[i]=1; >>>> col[j]=1; >>>> } >>>> >>>> scan agin >>>> if(row[i]==1 ||| col[j]==1) >>>> matrix[i][j]=0; >>>> >>>> >>>> two n*n loops so takes n*n and uses space too plz give me opt. soln >>>> >>>> On Fri, Sep 30, 2011 at 3:08 PM, Yogesh Yadav <medu...@gmail.com>wrote: >>>> >>>>> Already discussed >>>>> >>>>> >>>>> https://groups.google.com/group/algogeeks/browse_thread/thread/8a3e1a6665702f54/66bb2e804b43ae1d?hl=en&lnk=gst&q=MS+question+ankur#66bb2e804b43ae1d >>>>> >>>>> ..... >>>>> >>>>> >>>>> On Fri, Sep 30, 2011 at 2:59 PM, sumit kumar pathak < >>>>> sumitkp1...@gmail.com> wrote: >>>>> >>>>>> *find all the zeros in first iteration and store (size = array bool >>>>>> [2n])* >>>>>> *and then make zero. * >>>>>> *time = O(n^2)* >>>>>> *space = O(n)* >>>>>> * >>>>>> * >>>>>> *case 2:* >>>>>> * if any zero whole matrix zero, (once we get a zero its row and >>>>>> column will become zero which in turn lead to whole matrix being zero). >>>>>> * >>>>>> * >>>>>> *regards >>>>>> - Sumit Kumar Pathak >>>>>> (Sumit/ Pathak/ SKP ...) >>>>>> *Smile is only good contagious thing.* >>>>>> *Spread it*!!!!! >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> On Fri, Sep 30, 2011 at 2:38 PM, rahul sharma < >>>>>> rahul23111...@gmail.com> wrote: >>>>>> >>>>>>> it will zero only row not column >>>>>>> >>>>>>> On Fri, Sep 30, 2011 at 12:25 PM, Tamanna Afroze < >>>>>>> afroze...@gmail.com> wrote: >>>>>>> >>>>>>>> >>>>>>>> if(matrix[i][j]==0){ >>>>>>>> for(int j=0;j<n;j++) >>>>>>>> matrix[i][j]=0; >>>>>>>> } >>>>>>>> >>>>>>>> -- >>>>>>>> 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. >>>>>>>> >>>>>>> >>>>>>> -- >>>>>>> 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. >>>>>>> >>>>>> >>>>>> -- >>>>>> 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. >>>>>> >>>>> >>>>> -- >>>>> 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. >>>>> >>>> >>>> >>> >> -- >> 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. >> > > -- > 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. > -- 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.