got it..thnx yr On Tue, Oct 4, 2011 at 8:34 AM, rahul sharma <rahul23111...@gmail.com>wrote:
> so we shoul d aslo add loop at the top to find only for firrst row and > column the initial values > > > On Tue, Oct 4, 2011 at 8:30 AM, Ashish Goel <ashg...@gmail.com> wrote: > >> 0 in 0th row as well as 0 in 0th col and hence true >> >> >> Best Regards >> Ashish Goel >> "Think positive and find fuel in failure" >> +919985813081 >> +919966006652 >> >> >> On Tue, Oct 4, 2011 at 8:28 AM, rahul sharma <rahul23111...@gmail.com>wrote: >> >>> row0 and col0 initilayy true coz we have 0 in 0 row???or these r default >>> values? >>> >>> >>> On Tue, Oct 4, 2011 at 8:07 AM, Ashish Goel <ashg...@gmail.com> wrote: >>> >>>> 1 1 0 1 >>>> 0 1 1 1 >>>> 1 1 1 1 >>>> 1 1 1 0 >>>> >>>> row0 is true >>>> col0 is true >>>> >>>> for (int i=1; i<n;i++) >>>> for (int j=1;j<m;j++) >>>> if (a[i][j] == 0) {a[i][0]=0; a[0][j]=0;} >>>> >>>> now after this >>>> 1 1 0 0 >>>> 0 1 1 1 >>>> 1 1 1 1 >>>> 0 1 1 0 >>>> >>>> for (int i=1; i<n;i++) >>>> if (a[i][0] ==0) for (int j=1; j<m;j++) a[i][j]=0; >>>> for (int j=1; i<m;j++) >>>> if (a[0][j] ==0) for (int i=1; i<n;i++) a[i][j]=0; >>>> >>>> after this >>>> 1 1 0 0 >>>> 0 0 0 0 >>>> 1 1 0 0 >>>> 0 0 0 0 >>>> >>>> >>>> because of row0 and col0 vars >>>> >>>> >>>> final output is >>>> 0 0 0 0 >>>> 0 0 0 0 >>>> 0 1 0 0 >>>> 0 0 0 0 >>>> >>>> Best Regards >>>> Ashish Goel >>>> "Think positive and find fuel in failure" >>>> +919985813081 >>>> +919966006652 >>>> >>>> >>>> On Tue, Oct 4, 2011 at 7:49 AM, rahul sharma >>>> <rahul23111...@gmail.com>wrote: >>>> >>>>> @ashish can u give an xample.....plz...i have read a lot archives >>>>> ...but cant find in 0(1) space....u using 2 var only...plz give >>>>> xample...nended urgent.thnx >>>>> >>>>> >>>>> On Tue, Oct 4, 2011 at 7:26 AM, Ashish Goel <ashg...@gmail.com> wrote: >>>>> >>>>>> keep two var row0 and col0 for checking if there is any 0 in row0flag >>>>>> /col0flag >>>>>> >>>>>> now walk over elements from 1,1 to n,m and set corresponding entry in >>>>>> 0th row /column if you hit a zero. >>>>>> >>>>>> now walk over zeroth column and rwo and set the complete row/col if a >>>>>> 0 is there in 0th row/col. >>>>>> >>>>>> after this based on row0flag/col0flag, set oth col/row values to 0. >>>>>> >>>>>> Best Regards >>>>>> Ashish Goel >>>>>> "Think positive and find fuel in failure" >>>>>> +919985813081 >>>>>> +919966006652 >>>>>> >>>>>> >>>>>> >>>>>> On Mon, Oct 3, 2011 at 12:08 PM, rahul sharma < >>>>>> rahul23111...@gmail.com> wrote: >>>>>> >>>>>>> yeah it is wrong......i have a solution but uses 0(n+m) space.....i >>>>>>> need it in 0(n*m) tymand o(1) space >>>>>>> >>>>>>> >>>>>>> On Mon, Oct 3, 2011 at 11:55 AM, shady <sinv...@gmail.com> wrote: >>>>>>> >>>>>>>> search archives :-/ >>>>>>>> >>>>>>>> >>>>>>>> On Mon, Oct 3, 2011 at 11:47 AM, pranav agrawal < >>>>>>>> pranav.is.cool.agra...@gmail.com> wrote: >>>>>>>> >>>>>>>>> @rahul sharma, i ran this code, it is producing wrong answer :| >>>>>>>>> >>>>>>>>> check it, http://codepad.org/THv1hJq1 >>>>>>>>> >>>>>>>>> anyone with correct solution? >>>>>>>>> >>>>>>>>> -- >>>>>>>>> You received this message because you are subscribed to the Google >>>>>>>>> Groups "Algorithm Geeks" group. >>>>>>>>> To view this discussion on the web visit >>>>>>>>> https://groups.google.com/d/msg/algogeeks/-/26XU3UBqZ6EJ. >>>>>>>>> >>>>>>>>> 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. >>> >> >> -- >> 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.